/Volumes/GoogleDrive/My Drive/IB CS Resources/Final CS IA/20058_Computer_Science_IA/src/coreGUI/LibraryPanel.java |
1 /* public libraryPanel(ArrayList<setOfQs> setOfQsArr) {
2 initComponents();
3 } */
4
5 /*
6 * To change this license header, choose License Headers in Project Properties.
7 * To change this template file, choose Tools | Templates
8 * and open the template in the editor.
9 */
10 package coreGUI;
11
12 //Imports
13 import java.io.BufferedReader;
14 import java.io.FileReader;
15 import java.io.FileWriter;
16 import java.io.IOException;
17 import java.util.ArrayList;
18 import javax.swing.JFrame;
19 import javax.swing.JOptionPane;
20
21 /**
22 *
23 * @author 20058
24 */
25 public class LibraryPanel extends javax.swing.JFrame {
26 //ArrayList Declaration
27 private ArrayList<SetOfQs> setOfQsArr = new ArrayList<SetOfQs>();
28 /**
29 * Creates new form mainGUI
30 */
31
32 //loadSetOfQs read local file 'setofqsfile.txt to recreate the ArrayList that has information about all of the sets of questions
33 /**
34 Precondition:
35 */
36 private void loadSetOfQs(){
37 setOfQsArr = new ArrayList<SetOfQs>();
38 try{
39 FileReader fr = new FileReader("setofqsfile.txt");
40 BufferedReader br = new BufferedReader(fr);
41 String line=br.readLine();
42 while(line!=null){
43 String[] arr = line.split(";");
44 SetOfQs s = new SetOfQs(arr[0],Integer.parseInt(arr[1]),Integer.parseInt(arr[2]),
45 Double.parseDouble(arr[6]),Double.parseDouble(arr[4]),
46 Double.parseDouble(arr[5]),arr[3]);
47 setOfQsArr.add(s);
48 line = br.readLine();
49 }
50 }catch(IOException ex){
51
52 }
53 }
54
55 //saveSetOfQs writes to local file to add information about a new set of questions to setofqsfile.txt
56 public void saveSetOfQs(){
57 try{
58 String setOfQsFile = "setofqsfile.txt";
59 FileWriter fw = new FileWriter(setOfQsFile);
60 for(int i=0;i<setOfQsArr.size();i++){
61 fw.write(setOfQsArr.get(i).getSetOfQsName());
62 fw.write(";");
63 fw.write(setOfQsArr.get(i).getNumberOfQ()+"");
64 fw.write(";");
65 fw.write(setOfQsArr.get(i).getNumberOfChoices()+"");
66 fw.write(";");
67 fw.write(setOfQsArr.get(i).getNotes());
68 fw.write(";");
69 fw.write(setOfQsArr.get(i).getCorrectAnswerScore() + "");
70 fw.write(";");
71 fw.write(setOfQsArr.get(i).getIncorrectAnswerDeduction() + "");
72 fw.write(";");
73 fw.write(setOfQsArr.get(i).getInitialScore() + "");
74 if(i!=setOfQsArr.size()-1){
75 fw.write("\n");
76 }
77 }
78 fw.close();
79 } catch(IOException ex){
80 }
81 }
82
83
84
85
86 //library panel
87 public LibraryPanel() {
88 initComponents();
89 loadSetOfQs();
90
91 //sortButton's code for auto-sort after launch
92 String sortOption = sortByComboBox.getSelectedItem().toString();
93 if(sortOption.equals("Name (Descending)")){
94 SortAndSearchClass s = new SortAndSearchClass();
95 s.sortByNameDescending(setOfQsArr);
96 for(int row = 0 ; row < setOfQsArr.size(); row ++){
97 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
98 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
99 }
100 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
101 libraryTable.setValueAt(null, roww, 0);
102 libraryTable.setValueAt(null, roww, 1);
103 }
104 }
105 else if(sortOption.equals("Name (Ascending)")){
106 SortAndSearchClass s = new SortAndSearchClass();
107 s.sortByNameAscending(setOfQsArr);
108 for(int row = 0 ; row < setOfQsArr.size(); row ++){
109 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
110 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
111 }
112 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
113 libraryTable.setValueAt(null, roww, 0);
114 libraryTable.setValueAt(null, roww, 1);
115 }
116 }
117 else if(sortOption.equals("Number of Qs (Descending)")){
118 SortAndSearchClass s = new SortAndSearchClass();
119 s.sortByAmountDescending(setOfQsArr);
120 for(int row = 0 ; row < setOfQsArr.size(); row ++){
121 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
122 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
123 }
124 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
125 libraryTable.setValueAt(null, roww, 0);
126 libraryTable.setValueAt(null, roww, 1);
127 }
128 }
129 else if(sortOption.equals("Number of Qs (Ascending)")){
130 SortAndSearchClass s = new SortAndSearchClass();
131 s.sortByAmountAscending(setOfQsArr);
132 for(int row = 0 ; row < setOfQsArr.size(); row ++){
133 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
134 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
135 }
136 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
137 libraryTable.setValueAt(null, roww, 0);
138 libraryTable.setValueAt(null, roww, 1);
139 }
140 }
141
142 }
143
144 //windows' declaration
145 CreatePanel cWindow;
146 TestingSessionPanel tWindow;
147
148
}// </editor-fold>
642
643 private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {
644 // TODO add your handling code here:
645
646 }
647
648 private void searchTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
649 // TODO add your handling code here:
650 }
651
652 private void testButtonActionPerformed(java.awt.event.ActionEvent evt) {
653 // TODO add your handling code here:
654 }
655
656 private void sortButtonActionPerformed(java.awt.event.ActionEvent evt) {
657 // TODO add yo//ur handling code here:
658
659
660
661 }
662
663 private void testButtonMouseReleased(java.awt.event.MouseEvent evt) {
664 // TODO add your handling code here:
665 //Get a value from the selected row, create a new instance, let TestingSessionPanel take in setOfQsArr ArrayList of nth position.
666 int n = libraryTable.getSelectedRow();
667 Object valueCheck = libraryTable.getModel().getValueAt(n, 0);
668 if(valueCheck == null){
669 JOptionPane.showMessageDialog(this,"This is an empty row. Please select another row.", "Error", JOptionPane.ERROR_MESSAGE);
670 } else {
671 tWindow = new TestingSessionPanel(setOfQsArr.get(n));
672 tWindow.setVisible(true);
673 }
674 }
675
676 private void searchButtonMouseReleased(java.awt.event.MouseEvent evt) {
677 // TODO add your handling code here:
678 //Create a new instance of SortAndSearchClass so that sequentialSearch can take in setOfQsArr ArrayList and String from the searchTextField
679 SortAndSearchClass ss = new SortAndSearchClass();
680 int result = ss.sequentialSearch(setOfQsArr, searchTextField.getText());
681 if(result == -1){
682 //Display "Name not found" in the searchTextField when the item is not found
683 searchTextField.setText("\"Name not found\"");
684 }
685 else {
686 //But if found display the searched set of questions on the first row, set the value of the first element of setOfQsArr ArrayList as the searched set of questions, and display null for the remaining rows.
687 libraryTable.setValueAt(setOfQsArr.get(result).getSetOfQsName(), 0, 0);
688 libraryTable.setValueAt(setOfQsArr.get(result).getNumberOfQ(), 0, 1);
689 for(int row = 1 ; row < setOfQsArr.size(); row ++){
690 libraryTable.setValueAt(null, row, 0);
691 libraryTable.setValueAt(null, row, 1);
692 }
693 SetOfQs temp = setOfQsArr.get(0);
694 setOfQsArr.set(0, setOfQsArr.get(result));
695 setOfQsArr.set(result, temp);
696 }
697 }
698
699 private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {
700 // TODO add your handling code here:
701 }
702
703 private void deleteButtonMouseReleased(java.awt.event.MouseEvent evt) {
704 int n = libraryTable.getSelectedRow();
705 Object valueCheck = libraryTable.getModel().getValueAt(n, 0);
706 if(valueCheck == null){
707 JOptionPane.showMessageDialog(this,"This is an empty row. Please select another row.", "Error", JOptionPane.ERROR_MESSAGE);
708 } else {
709 //Imported JFrame for delete confirmation pop-ups
710 JFrame f;
711 f = new JFrame();
712 int delItem = libraryTable.getSelectedRow();
713 int a = JOptionPane.showConfirmDialog(f, "Are you sure?");
714 if (a == JOptionPane.YES_OPTION) {
715 setOfQsArr.remove(delItem);
716 }
717 //run saveSetOfQs, loadSetOfQs, and sortButton's code to refresh the table and to make libraryTable take in and display the latest version of setofqsfile.txt
718 saveSetOfQs();
719 loadSetOfQs();
720 String sortOption = sortByComboBox.getSelectedItem().toString();
721 if(sortOption.equals("Name (Descending)")){
722 SortAndSearchClass s = new SortAndSearchClass();
723 s.sortByNameDescending(setOfQsArr);
724 for(int row = 0 ; row < setOfQsArr.size(); row ++){
725 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
726 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
727 }
728 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
729 libraryTable.setValueAt(null, roww, 0);
730 libraryTable.setValueAt(null, roww, 1);
731 }
732 }
733 else if(sortOption.equals("Name (Ascending)")){
734 SortAndSearchClass s = new SortAndSearchClass();
735 s.sortByNameAscending(setOfQsArr);
736 for(int row = 0 ; row < setOfQsArr.size(); row ++){
737 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
738 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
739 }
740 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
741 libraryTable.setValueAt(null, roww, 0);
742 libraryTable.setValueAt(null, roww, 1);
743 }
744 }
745 else if(sortOption.equals("Number of Qs (Descending)")){
746 SortAndSearchClass s = new SortAndSearchClass();
747 s.sortByAmountDescending(setOfQsArr);
748 for(int row = 0 ; row < setOfQsArr.size(); row ++){
749 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
750 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
751 }
752 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
753 libraryTable.setValueAt(null, roww, 0);
754 libraryTable.setValueAt(null, roww, 1);
755 }
756 }
757 else if(sortOption.equals("Number of Qs (Ascending)")){
758 SortAndSearchClass s = new SortAndSearchClass();
759 s.sortByAmountAscending(setOfQsArr);
760 for(int row = 0 ; row < setOfQsArr.size(); row ++){
761 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
762 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
763 }
764 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
765 libraryTable.setValueAt(null, roww, 0);
766 libraryTable.setValueAt(null, roww, 1);
767 }
768 }
769 }
770
771 }
772
773 private void sortButtonMouseReleased(java.awt.event.MouseEvent evt) {
774 // TODO add your handling code here:
775 //Use loadSetOfQs to create setOfQs ArrayList from the latest version of setofqsfile.txt
776 loadSetOfQs();
777
778 //sortButton sorts according to what was selected in the sortByComboBox
779 String sortOption = sortByComboBox.getSelectedItem().toString();
780 if(sortOption.equals("Name (Descending)")){
781 SortAndSearchClass s = new SortAndSearchClass();
782
783 //Uses different sorting method for each sorting option in the sortByComboBox
784 s.sortByNameDescending(setOfQsArr);
785
786 //for loop for displaying set(s) of questions' name and number of question on the table
787 for(int row = 0 ; row < setOfQsArr.size(); row ++){
788 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
789 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
790 }
791
792 //for loop for setting rows and columns that go beyond the size of setOfQsArr as null
793 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
794 libraryTable.setValueAt(null, roww, 0);
795 libraryTable.setValueAt(null, roww, 1);
796 }
797 }
798 else if(sortOption.equals("Name (Ascending)")){
799 SortAndSearchClass s = new SortAndSearchClass();
800 s.sortByNameAscending(setOfQsArr);
801 for(int row = 0 ; row < setOfQsArr.size(); row ++){
802 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
803 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
804 }
805 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
806 libraryTable.setValueAt(null, roww, 0);
807 libraryTable.setValueAt(null, roww, 1);
808 }
809 }
810 else if(sortOption.equals("Number of Qs (Descending)")){
811 SortAndSearchClass s = new SortAndSearchClass();
812 s.sortByAmountDescending(setOfQsArr);
813 for(int row = 0 ; row < setOfQsArr.size(); row ++){
814 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
815 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
816 }
817 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
818 libraryTable.setValueAt(null, roww, 0);
819 libraryTable.setValueAt(null, roww, 1);
820 }
821 }
822 else if(sortOption.equals("Number of Qs (Ascending)")){
823 SortAndSearchClass s = new SortAndSearchClass();
824 s.sortByAmountAscending(setOfQsArr);
825 for(int row = 0 ; row < setOfQsArr.size(); row ++){
826 libraryTable.setValueAt(setOfQsArr.get(row).getSetOfQsName(), row, 0);
827 libraryTable.setValueAt(setOfQsArr.get(row).getNumberOfQ(), row, 1);
828 }
829 for(int roww = setOfQsArr.size() ; roww < 100; roww ++){
830 libraryTable.setValueAt(null, roww, 0);
831 libraryTable.setValueAt(null, roww, 1);
832 }
833 }
834
835 }
836
837 private void createMenuKeyReleased(java.awt.event.KeyEvent evt) {
838 // TODO add your handling code here:
839
840 // CreatePanel is created and is set to visible
841 cWindow = new CreatePanel();
842 cWindow.setVisible(true);
843 }
844
845 private void createMenuActionPerformed(java.awt.event.ActionEvent evt) {
846 // TODO add your handling code here:
847
848 }
849
850 private void createMenuMouseReleased(java.awt.event.MouseEvent evt) {
851 // TODO add your handling code here:
852
853 // CreatePanel is created and is set to visible
854 cWindow = new CreatePanel();
855 cWindow.setVisible(true);
856
857 }
858
859
860
861
862
863
864
865 /**
866 * @param args the command line arguments
867 */
868 public static void main(String args[]) {
869 /* Set the Nimbus look and feel */
870 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
871 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
872 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
873 */
874 try {
875 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
876 if ("Nimbus".equals(info.getName())) {
877 javax.swing.UIManager.setLookAndFeel(info.getClassName());
878 break;
879 }
880 }
881 } catch (ClassNotFoundException ex) {
882 java.util.logging.Logger.getLogger(LibraryPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
883 } catch (InstantiationException ex) {
884 java.util.logging.Logger.getLogger(LibraryPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
885 } catch (IllegalAccessException ex) {
886 java.util.logging.Logger.getLogger(LibraryPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
887 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
888 java.util.logging.Logger.getLogger(LibraryPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
889 }
890 //</editor-fold>
891 //</editor-fold>
892 //</editor-fold>
893 //</editor-fold>
894
895 /* Create and display the form */
896 java.awt.EventQueue.invokeLater(new Runnable() {
897 public void run() {
898 new LibraryPanel().setVisible(true);
899 }
900 });
901 }
902
/*#######################################################################################################################################
##############################NOTE THAT ALL CODE WHICH IS HIGHLIGHTED BY THE GREY BLOCK IS AUTO-GENERATED FROM#################
##################################NETBEANS, (mainly the GUI stuff)#############################################################################
############################################################################################################################################
############################################################################################################################################
############################################################################################################################################ */
149 /**
150 * This method is called from within the constructor to initialize the form.
151 * WARNING: Do NOT modify this code. The content of this method is always
152 * regenerated by the Form Editor.
153 */
154 @SuppressWarnings("unchecked")
155 // <editor-fold defaultstate="collapsed" desc="Generated Code">
156 private void initComponents() {
157
158 libPanel = new javax.swing.JPanel();
159 deleteButton = new javax.swing.JButton();
160 testButton = new javax.swing.JButton();
161 searchTextField = new javax.swing.JTextField();
162 sortByLabel = new javax.swing.JLabel();
163 searchButton = new javax.swing.JButton();
164 sortByComboBox = new javax.swing.JComboBox<>();
165 libScrollPane = new javax.swing.JScrollPane();
166 libraryTable = new javax.swing.JTable();
167 sortButton = new javax.swing.JButton();
168 libraryMenuBar = new javax.swing.JMenuBar();
169 libraryMenu = new javax.swing.JMenu();
170 createMenu = new javax.swing.JMenuItem();
171
172 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
173 setResizable(false);
174
175 deleteButton.setText("Delete");
176 deleteButton.addMouseListener(new java.awt.event.MouseAdapter() {
177 public void mouseReleased(java.awt.event.MouseEvent evt) {
178 deleteButtonMouseReleased(evt);
179 }
180 });
181 deleteButton.addActionListener(new java.awt.event.ActionListener() {
182 public void actionPerformed(java.awt.event.ActionEvent evt) {
183 deleteButtonActionPerformed(evt);
184 }
185 });
186
187 testButton.setText("Test");
188 testButton.addMouseListener(new java.awt.event.MouseAdapter() {
189 public void mouseReleased(java.awt.event.MouseEvent evt) {
190 testButtonMouseReleased(evt);
191 }
192 });
193 testButton.addActionListener(new java.awt.event.ActionListener() {
194 public void actionPerformed(java.awt.event.ActionEvent evt) {
195 testButtonActionPerformed(evt);
196 }
197 });
198
199 searchTextField.addActionListener(new java.awt.event.ActionListener() {
200 public void actionPerformed(java.awt.event.ActionEvent evt) {
201 searchTextFieldActionPerformed(evt);
202 }
203 });
204
205 sortByLabel.setText("Sort by:");
206
207 searchButton.setText("Find");
208 searchButton.addMouseListener(new java.awt.event.MouseAdapter() {
209 public void mouseReleased(java.awt.event.MouseEvent evt) {
210 searchButtonMouseReleased(evt);
211 }
212 });
213 searchButton.addActionListener(new java.awt.event.ActionListener() {
214 public void actionPerformed(java.awt.event.ActionEvent evt) {
215 searchButtonActionPerformed(evt);
216 }
217 });
218
219 sortByComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Name (Descending)", "Name (Ascending)", "Number of Qs (Descending)", "Number of Qs (Ascending)", " " }));
220
221 libraryTable.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
222 libraryTable.setModel(new javax.swing.table.DefaultTableModel(
223 new Object [][] {
224 {null, null},
225 {null, null},
226 {null, null},
227 {null, null},
228 {null, null},
229 {null, null},
230 {null, null},
231 {null, null},
232 {null, null},
233 {null, null},
234 {null, null},
235 {null, null},
236 {null, null},
237 {null, null},
238 {null, null},
239 {null, null},
240 {null, null},
241 {null, null},
242 {null, null},
243 {null, null},
244 {null, null},
245 {null, null},
246 {null, null},
247 {null, null},
248 {null, null},
249 {null, null},
250 {null, null},
251 {null, null},
252 {null, null},
253 {null, null},
254 {null, null},
255 {null, null},
256 {null, null},
257 {null, null},
258 {null, null},
259 {null, null},
260 {null, null},
261 {null, null},
262 {null, null},
263 {null, null},
264 {null, null},
265 {null, null},
266 {null, null},
267 {null, null},
268 {null, null},
269 {null, null},
270 {null, null},
271 {null, null},
272 {null, null},
273 {null, null},
274 {null, null},
275 {null, null},
276 {null, null},
277 {null, null},
278 {null, null},
279 {null, null},
280 {null, null},
281 {null, null},
282 {null, null},
283 {null, null},
284 {null, null},
285 {null, null},
286 {null, null},
287 {null, null},
288 {null, null},
289 {null, null},
290 {null, null},
291 {null, null},
292 {null, null},
293 {null, null},
294 {null, null},
295 {null, null},
296 {null, null},
297 {null, null},
298 {null, null},
299 {null, null},
300 {null, null},
301 {null, null},
302 {null, null},
303 {null, null},
304 {null, null},
305 {null, null},
306 {null, null},
307 {null, null},
308 {null, null},
309 {null, null},
310 {null, null},
311 {null, null},
312 {null, null},
313 {null, null},
314 {null, null},
315 {null, null},
316 {null, null},
317 {null, null},
318 {null, null},
319 {null, null},
320 {null, null},
321 {null, null},
322 {null, null},
323 {null, null},
324 {null, null},
325 {null, null},
326 {null, null},
327 {null, null},
328 {null, null},
329 {null, null},
330 {null, null},
331 {null, null},
332 {null, null},
333 {null, null},
334 {null, null},
335 {null, null},
336 {null, null},
337 {null, null},
338 {null, null},
339 {null, null},
340 {null, null},
341 {null, null},
342 {null, null},
343 {null, null},
344 {null, null},
345 {null, null},
346 {null, null},
347 {null, null},
348 {null, null},
349 {null, null},
350 {null, null},
351 {null, null},
352 {null, null},
353 {null, null},
354 {null, null},
355 {null, null},
356 {null, null},
357 {null, null},
358 {null, null},
359 {null, null},
360 {null, null},
361 {null, null},
362 {null, null},
363 {null, null},
364 {null, null},
365 {null, null},
366 {null, null},
367 {null, null},
368 {null, null},
369 {null, null},
370 {null, null},
371 {null, null},
372 {null, null},
373 {null, null},
374 {null, null},
375 {null, null},
376 {null, null},
377 {null, null},
378 {null, null},
379 {null, null},
380 {null, null},
381 {null, null},
382 {null, null},
383 {null, null},
384 {null, null},
385 {null, null},
386 {null, null},
387 {null, null},
388 {null, null},
389 {null, null},
390 {null, null},
391 {null, null},
392 {null, null},
393 {null, null},
394 {null, null},
395 {null, null},
396 {null, null},
397 {null, null},
398 {null, null},
399 {null, null},
400 {null, null},
401 {null, null},
402 {null, null},
403 {null, null},
404 {null, null},
405 {null, null},
406 {null, null},
407 {null, null},
408 {null, null},
409 {null, null},
410 {null, null},
411 {null, null},
412 {null, null},
413 {null, null},
414 {null, null},
415 {null, null},
416 {null, null},
417 {null, null},
418 {null, null},
419 {null, null},
420 {null, null},
421 {null, null},
422 {null, null},
423 {null, null},
424 {null, null},
425 {null, null},
426 {null, null},
427 {null, null},
428 {null, null},
429 {null, null},
430 {null, null},
431 {null, null},
432 {null, null},
433 {null, null},
434 {null, null},
435 {null, null},
436 {null, null},
437 {null, null},
438 {null, null},
439 {null, null},
440 {null, null},
441 {null, null},
442 {null, null},
443 {null, null},
444 {null, null},
445 {null, null},
446 {null, null},
447 {null, null},
448 {null, null},
449 {null, null},
450 {null, null},
451 {null, null},
452 {null, null},
453 {null, null},
454 {null, null},
455 {null, null},
456 {null, null},
457 {null, null},
458 {null, null},
459 {null, null},
460 {null, null},
461 {null, null},
462 {null, null},
463 {null, null},
464 {null, null},
465 {null, null},
466 {null, null},
467 {null, null},
468 {null, null},
469 {null, null},
470 {null, null},
471 {null, null},
472 {null, null},
473 {null, null},
474 {null, null},
475 {null, null},
476 {null, null},
477 {null, null},
478 {null, null},
479 {null, null},
480 {null, null},
481 {null, null},
482 {null, null},
483 {null, null},
484 {null, null},
485 {null, null},
486 {null, null},
487 {null, null},
488 {null, null},
489 {null, null},
490 {null, null},
491 {null, null},
492 {null, null},
493 {null, null},
494 {null, null},
495 {null, null},
496 {null, null},
497 {null, null},
498 {null, null},
499 {null, null},
500 {null, null},
501 {null, null},
502 {null, null},
503 {null, null},
504 {null, null},
505 {null, null},
506 {null, null},
507 {null, null},
508 {null, null},
509 {null, null},
510 {null, null},
511 {null, null},
512 {null, null},
513 {null, null},
514 {null, null},
515 {null, null},
516 {null, null},
517 {null, null},
518 {null, null},
519 {null, null},
520 {null, null},
521 {null, null},
522 {null, null},
523 {null, null}
524 },
525 new String [] {
526 "Name", "Amount of Question"
527 }
528 ) {
529 Class[] types = new Class [] {
530 java.lang.String.class, java.lang.Integer.class
531 };
532
533 public Class getColumnClass(int columnIndex) {
534 return types [columnIndex];
535 }
536 });
537 libScrollPane.setViewportView(libraryTable);
538
539 sortButton.setText("Reload");
540 sortButton.addMouseListener(new java.awt.event.MouseAdapter() {
541 public void mouseReleased(java.awt.event.MouseEvent evt) {
542 sortButtonMouseReleased(evt);
543 }
544 });
545 sortButton.addActionListener(new java.awt.event.ActionListener() {
546 public void actionPerformed(java.awt.event.ActionEvent evt) {
547 sortButtonActionPerformed(evt);
548 }
549 });
550
551 javax.swing.GroupLayout libPanelLayout = new javax.swing.GroupLayout(libPanel);
552 libPanel.setLayout(libPanelLayout);
553 libPanelLayout.setHorizontalGroup(
554 libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
555 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, libPanelLayout.createSequentialGroup()
556 .addContainerGap()
557 .addComponent(libScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 496, Short.MAX_VALUE)
558 .addContainerGap())
559 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, libPanelLayout.createSequentialGroup()
560 .addGap(0, 0, Short.MAX_VALUE)
561 .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
562 .addComponent(searchTextField)
563 .addGroup(libPanelLayout.createSequentialGroup()
564 .addComponent(sortByLabel)
565 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
566 .addComponent(sortByComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)))
567 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
568 .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
569 .addComponent(searchButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
570 .addComponent(sortButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
571 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, libPanelLayout.createSequentialGroup()
572 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
573 .addComponent(testButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
574 .addGap(18, 18, 18)
575 .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
576 .addGap(143, 143, 143))
577 );
578 libPanelLayout.setVerticalGroup(
579 libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
580 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, libPanelLayout.createSequentialGroup()
581 .addContainerGap()
582 .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
583 .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
584 .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
585 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
586 .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
587 .addComponent(sortByLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
588 .addComponent(sortByComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
589 .addComponent(sortButton))
590 .addGap(18, 18, Short.MAX_VALUE)
591 .addComponent(libScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE)
592 .addGap(18, 18, 18)
593 .addGroup(libPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
594 .addComponent(testButton)
595 .addComponent(deleteButton))
596 .addGap(20, 20, 20))
597 );
598
599 libraryMenu.setText("File");
600
601 createMenu.setText("New Set Of Question(s)");
602 createMenu.addMouseListener(new java.awt.event.MouseAdapter() {
603 public void mouseReleased(java.awt.event.MouseEvent evt) {
604 createMenuMouseReleased(evt);
605 }
606 });
607 createMenu.addActionListener(new java.awt.event.ActionListener() {
608 public void actionPerformed(java.awt.event.ActionEvent evt) {
609 createMenuActionPerformed(evt);
610 }
611 });
612 createMenu.addKeyListener(new java.awt.event.KeyAdapter() {
613 public void keyReleased(java.awt.event.KeyEvent evt) {
614 createMenuKeyReleased(evt);
615 }
616 });
617 libraryMenu.add(createMenu);
618
619 libraryMenuBar.add(libraryMenu);
620
621 setJMenuBar(libraryMenuBar);
622
623 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
624 getContentPane().setLayout(layout);
625 layout.setHorizontalGroup(
626 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
627 .addGroup(layout.createSequentialGroup()
628 .addContainerGap(45, Short.MAX_VALUE)
629 .addComponent(libPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
630 .addGap(45, 45, 45))
631 );
632 layout.setVerticalGroup(
633 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
634 .addGroup(layout.createSequentialGroup()
635 .addGap(20, 20, 20)
636 .addComponent(libPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
637 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
638 );
639
640 pack();
641
903
904
905 // Variables declaration - do not modify
906 private javax.swing.JMenuItem createMenu;
907 private javax.swing.JButton deleteButton;
908 private javax.swing.JPanel libPanel;
909 private javax.swing.JScrollPane libScrollPane;
910 private javax.swing.JMenu libraryMenu;
911 private javax.swing.JMenuBar libraryMenuBar;
912 private javax.swing.JTable libraryTable;
913 private javax.swing.JButton searchButton;
914 private javax.swing.JTextField searchTextField;
915 private javax.swing.JButton sortButton;
916 private javax.swing.JComboBox<String> sortByComboBox;
917 private javax.swing.JLabel sortByLabel;
918 private javax.swing.JButton testButton;
919 // End of variables declaration
920 }
921