private void listOfQuestionsValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: int index = listOfQuestions.getSelectedIndex(); questionLabel.setText(questions.get(index)); answerList.setSelectedIndex(index); pointList.setSelectedIndex(index); }
private void listOfNamesValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: int index = listOfNames.getSelectedIndex(); // System.out.println(index); listModel3.clear(); listModel4.clear(); for (int i = 0; i < 5; i++) { listModel3.addElement((answers.get(index))[i]); } answerList.setModel(listModel3); for (int i = 0; i < 5; i++) { if ((answers.get(index))[i] == correct[i]) { listModel4.addElement("2/2"); } else { listModel4.addElement("0/2"); } } pointList.setModel(listModel4); }
/** Creates new form NewJFrame */ public GraderUI() { initComponents(); listModel = new DefaultListModel(); listModel2 = new DefaultListModel(); listModel3 = new DefaultListModel(); listModel4 = new DefaultListModel(); names.add("Kevin Pham"); names.add("RJ Almada"); names.add("Alvin Lam"); names.add("Neil Nordhof"); names.add("Grant Pickett"); names.add("Yuliya Levitskaya"); answers.add(kevinAns); answers.add(RJAns); answers.add(alvinAns); answers.add(neilAns); answers.add(grantAns); answers.add(yuliyaAns); questions.add("True or False: A function cannot be defined inside another function. (2 pts)"); questions.add("True or False: Functions cannot return more than one value at a time. (2 pts)"); questions.add( "True or False: If return type for a function is not specified, it defaults to int. (2 pts)"); questions.add("True or False: Functions can be called either by value or reference. (2 pts)"); questions.add( "True or False: A function may have any number of return statements each returning different values. (2 pts)"); for (int i = 0; i < names.size(); i++) { listModel.addElement(names.get(i)); } for (int i = 0; i < 5; i++) { listModel2.addElement("Question " + (i + 1)); } listOfNames.setModel(listModel); listOfQuestions.setModel(listModel2); listOfNames.setSelectedIndex(0); listOfQuestions.setSelectedIndex(0); setVisible(true); }