/* * Copyright (c) 2012 Patrick Meyer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.itemanalysis.jmetrik.gui; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class SpecialCodeDialog extends JDialog { // Variables declaration - do not modify private JButton cancelButton; private JPanel mainPanel; private JLabel missLabel; private JLabel missLabel1; private JLabel missLabel2; private JComboBox missingComboBox; private JComboBox notReachedComboBox; private JButton okButton; private JComboBox omittedComboBox; // End of variables declaration public SpecialCodeDialog(JDialog parent){ super(parent, "Special Codes", true); initComponents(); setLocationRelativeTo(parent); setResizable(false); } private void initComponents() { mainPanel = new JPanel(); missLabel = new JLabel(); missingComboBox = new JComboBox(); missLabel1 = new JLabel(); omittedComboBox = new JComboBox(); missLabel2 = new JLabel(); notReachedComboBox = new JComboBox(); okButton = new JButton(); cancelButton = new JButton(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Special Codes"); mainPanel.setBorder(BorderFactory.createTitledBorder("Treament of Special Codes")); missLabel.setText("Missing response"); missingComboBox.setModel(new DefaultComboBoxModel(new String[] { "Score as zero", "Ignore" })); missingComboBox.setMaximumSize(new Dimension(110, 28)); missingComboBox.setMinimumSize(new Dimension(110, 28)); missingComboBox.setPreferredSize(new Dimension(110, 28)); missLabel1.setText("Omitted response"); omittedComboBox.setModel(new DefaultComboBoxModel(new String[] { "Score as zero", "Ignore" })); omittedComboBox.setMaximumSize(new Dimension(110, 28)); omittedComboBox.setMinimumSize(new Dimension(110, 28)); omittedComboBox.setPreferredSize(new Dimension(110, 28)); missLabel2.setText("Not reached response"); notReachedComboBox.setModel(new DefaultComboBoxModel(new String[] { "Score as zero", "Ignore" })); notReachedComboBox.setMaximumSize(new Dimension(110, 28)); notReachedComboBox.setMinimumSize(new Dimension(110, 28)); notReachedComboBox.setPreferredSize(new Dimension(110, 28)); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addGroup(mainPanelLayout.createSequentialGroup() .addComponent(missLabel1) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(omittedComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(mainPanelLayout.createSequentialGroup() .addComponent(missLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(missingComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(mainPanelLayout.createSequentialGroup() .addComponent(missLabel2) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(notReachedComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); mainPanelLayout.setVerticalGroup( mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(missLabel) .addComponent(missingComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(missLabel1) .addComponent(omittedComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(missLabel2) .addComponent(notReachedComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); okButton.setText("OK"); okButton.setMaximumSize(new Dimension(72, 28)); okButton.setMinimumSize(new Dimension(72, 28)); okButton.setPreferredSize(new Dimension(72, 28)); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //To change body of implemented methods use File | Settings | File Templates. } }); cancelButton.setText("Cancel"); cancelButton.setMaximumSize(new Dimension(72, 28)); cancelButton.setMinimumSize(new Dimension(72, 28)); cancelButton.setPreferredSize(new Dimension(72, 28)); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(mainPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(okButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(mainPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(okButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> }