import javax.swing.table.AbstractTableModel; /* * QuestionSelection.java * * Created on October 20, 2003, 10:36 PM */ /** * * @author Matt */ public class QuestionSelection extends javax.swing.JFrame { /** Creates new form QuestionSelection */ public QuestionSelection() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; buttonPanel = new javax.swing.JPanel(); removeButton = new javax.swing.JButton(); addButton = new javax.swing.JButton(); expandingPanel = new javax.swing.JPanel(); usedQuestionsPane = new javax.swing.JScrollPane(); questionTable = new javax.swing.JTable(); availableQuestionsPane = new javax.swing.JScrollPane(); questionTable1 = new javax.swing.JTable(); lowerContentPanel = new javax.swing.JPanel(); filterPanel = new javax.swing.JPanel(); authorLabel = new javax.swing.JLabel(); classLabel = new javax.swing.JLabel(); timeLabel = new javax.swing.JLabel(); difficultyLabel = new javax.swing.JLabel(); pointValueLabel = new javax.swing.JLabel(); authorField = new javax.swing.JTextField(); classField = new javax.swing.JTextField(); timeField = new javax.swing.JTextField(); difficultyField = new javax.swing.JTextField(); pointValueField = new javax.swing.JTextField(); typePanel = new javax.swing.JPanel(); trueFalseRadio = new javax.swing.JRadioButton(); multipleChoiceRadio = new javax.swing.JRadioButton(); shortResponseRadio = new javax.swing.JRadioButton(); matchingRadio = new javax.swing.JRadioButton(); essayRadio = new javax.swing.JRadioButton(); programmingRadio = new javax.swing.JRadioButton(); filterButton = new javax.swing.JButton(); labelPanel = new javax.swing.JPanel(); usedQuestionsLabel = new javax.swing.JLabel(); availableQuestionsLabel = new javax.swing.JLabel(); setTitle("Question Selection"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); removeButton.setText("Remove"); buttonPanel.add(removeButton); addButton.setText("Add"); buttonPanel.add(addButton); getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH); expandingPanel.setLayout(new java.awt.GridBagLayout()); usedQuestionsPane.setMinimumSize(new java.awt.Dimension(300, 300)); questionTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); final String[] names = {"Question", "Author", "Class", "Time taken", "Difficulty", "PointValue"}; questionTable.setModel(new AbstractTableModel() { private final Object[][] data = { {"What is the air-speed velocity of an unlaiden swallow?", "Turner", "DUH101", "1", "6", "5"}, {"What is the meaning of life?", "Socrates", "PHIL 101", "999", "10", "2"}, {"Please code in Java a program that outputs the words \"Hello World\".", "Dalbey", "CSC205", "10", "10", "100"} }; public int getRowCount() {return 3;} public int getColumnCount() {return 6;} public Object getValueAt(int row, int column) { return data[row][column]; } public String getColumnName(int i) { return names[i]; } }); usedQuestionsPane.setViewportView(questionTable); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.5; gridBagConstraints.weighty = 0.85; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10); expandingPanel.add(usedQuestionsPane, gridBagConstraints); availableQuestionsPane.setMinimumSize(new java.awt.Dimension(300, 300)); availableQuestionsPane.setPreferredSize(new java.awt.Dimension(453, 403)); questionTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); //final String[] names = {"Question", "Author", "Class", "Time taken", "Difficulty", "PointValue"}; questionTable1.setModel(new AbstractTableModel() { private final Object[][] data = { {"What is the air-speed velocity of an unlaiden swallow?", "Turner", "DUH101", "1", "6", "5"}, {"What is the meaning of life?", "Socrates", "PHIL 101", "999", "10", "2"}, {"Please code in Java a program that outputs the words \"Hello World\".", "Dalbey", "CSC205", "10", "10", "100"} }; public int getRowCount() {return 3;} public int getColumnCount() {return 6;} public Object getValueAt(int row, int column) { return data[row][column]; } public String getColumnName(int i) { return names[i]; } }); availableQuestionsPane.setViewportView(questionTable1); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.5; gridBagConstraints.weighty = 0.85; gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0); expandingPanel.add(availableQuestionsPane, gridBagConstraints); filterPanel.setLayout(new java.awt.GridBagLayout()); filterPanel.setBorder(new javax.swing.border.TitledBorder("Search Criteria")); authorLabel.setText("Author"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); filterPanel.add(authorLabel, gridBagConstraints); classLabel.setText("Class"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); filterPanel.add(classLabel, gridBagConstraints); timeLabel.setText("Time taken (minutes)"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); filterPanel.add(timeLabel, gridBagConstraints); difficultyLabel.setText("Difficulty"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); filterPanel.add(difficultyLabel, gridBagConstraints); pointValueLabel.setText("Point value"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); filterPanel.add(pointValueLabel, gridBagConstraints); authorField.setText("Schmoe"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); filterPanel.add(authorField, gridBagConstraints); classField.setText("CSC101 Midterm 1"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); filterPanel.add(classField, gridBagConstraints); timeField.setText("10-15"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); filterPanel.add(timeField, gridBagConstraints); difficultyField.setText("9"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 7; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); filterPanel.add(difficultyField, gridBagConstraints); pointValueField.setText("15"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 9; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); filterPanel.add(pointValueField, gridBagConstraints); typePanel.setLayout(new java.awt.GridLayout(6, 1)); typePanel.setBorder(new javax.swing.border.TitledBorder("Type")); trueFalseRadio.setText("True/false"); typePanel.add(trueFalseRadio); multipleChoiceRadio.setText("Multiple choice"); typePanel.add(multipleChoiceRadio); shortResponseRadio.setText("Short response"); typePanel.add(shortResponseRadio); matchingRadio.setText("Matching"); typePanel.add(matchingRadio); essayRadio.setText("Essay"); typePanel.add(essayRadio); programmingRadio.setText("Programming"); typePanel.add(programmingRadio); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 8; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); filterPanel.add(typePanel, gridBagConstraints); filterButton.setText("Search"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 9; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10); filterPanel.add(filterButton, gridBagConstraints); lowerContentPanel.add(filterPanel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0); expandingPanel.add(lowerContentPanel, gridBagConstraints); getContentPane().add(expandingPanel, java.awt.BorderLayout.CENTER); labelPanel.setLayout(new java.awt.GridLayout(1, 2)); usedQuestionsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); usedQuestionsLabel.setText("Questions in test"); labelPanel.add(usedQuestionsLabel); availableQuestionsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); availableQuestionsLabel.setText("Question bank search"); labelPanel.add(availableQuestionsLabel); getContentPane().add(labelPanel, java.awt.BorderLayout.NORTH); pack(); }//GEN-END:initComponents /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main(String args[]) { new QuestionSelection().show(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addButton; private javax.swing.JTextField authorField; private javax.swing.JLabel authorLabel; private javax.swing.JLabel availableQuestionsLabel; private javax.swing.JScrollPane availableQuestionsPane; private javax.swing.JPanel buttonPanel; private javax.swing.JTextField classField; private javax.swing.JLabel classLabel; private javax.swing.JTextField difficultyField; private javax.swing.JLabel difficultyLabel; private javax.swing.JRadioButton essayRadio; private javax.swing.JPanel expandingPanel; private javax.swing.JButton filterButton; private javax.swing.JPanel filterPanel; private javax.swing.JPanel labelPanel; private javax.swing.JPanel lowerContentPanel; private javax.swing.JRadioButton matchingRadio; private javax.swing.JRadioButton multipleChoiceRadio; private javax.swing.JTextField pointValueField; private javax.swing.JLabel pointValueLabel; private javax.swing.JRadioButton programmingRadio; private javax.swing.JTable questionTable; private javax.swing.JTable questionTable1; private javax.swing.JButton removeButton; private javax.swing.JRadioButton shortResponseRadio; private javax.swing.JTextField timeField; private javax.swing.JLabel timeLabel; private javax.swing.JRadioButton trueFalseRadio; private javax.swing.JPanel typePanel; private javax.swing.JLabel usedQuestionsLabel; private javax.swing.JScrollPane usedQuestionsPane; // End of variables declaration//GEN-END:variables }