private void apply() { String action = (String) StatusList.getSelectedItem(); Person p = (Person) PersonList.getSelectedItem(); Course c = (Course) CourseList.getSelectedItem(); if (!checkValidAction(action, p, c)) { System.err.println("Invalid action... Ignoring..."); return; } StatusList.setSelectedIndex(0); PersonList.setSelectedIndex(0); CourseList.setSelectedIndex(0); char[] password = null; try { password = PrivateKeyHandler.checkPassword( GenerateKeys.getPasswordInput()); // This window shows garbage if (password == null) { System.err.println("Please enter admin password to apply changes"); return; } if (action == STUDENT) { LoginManager.setStudent(p.getPID(), c.getCID()); } else if (action == TA) { LoginManager.setTA(p.getPID(), c.getCID()); } else if (action == PROF) { LoginManager.setProf(p.getPID(), c.getCID()); } else if (action == REMOVE) { LoginManager.remove(p.getPID(), c.getCID()); } else if (action == REMOVEPERSON) { LoginManager.remove(p.getPID()); } else if (action == REMOVECOURSE) { LoginManager.removeCourse(c.getCID()); } else if (action == EDITCOURSE) { JTextField pf = new JTextField(); int okCxl = JOptionPane.showConfirmDialog( null, pf, "Change Course name to", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); String courseName = null; if (okCxl == JOptionPane.OK_OPTION) { courseName = new String(pf.getText()); } else { return; } LoginManager.changeCoursename(c.getCID(), courseName); } else if (action == EDITUSERNAME) { JTextField pf = new JTextField(); int okCxl = JOptionPane.showConfirmDialog( null, pf, "Change username to", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); String username = null; if (okCxl == JOptionPane.OK_OPTION) { username = new String(pf.getText()); } else { return; } LoginManager.changeUsername(p.getPID(), username); } enc = LoginManager.save(password); } finally { if (password != null) { for (int i = 0; i < password.length; i++) { password[i] = '\0'; } } } }