我已经标记了给我带来麻烦的行
private void EditButtonActionPerformed(java.awt.event.ActionEvent evt) {
DefaultListModel PatientListModel = new DefaultListModel();
for (Patient s : PatientList) {
int AccNum = Integer.parseInt(IDTextField.getText());
if (AccNum == s.getAccountNumber()) {
s.setName(NameTextField.getText());
s.setAge(Integer.parseInt(AgeTextField.getText()));
s.setAddress(AddressTextField.getText());
String PatientSex = "";
if (MaleRadioButton.isSelected()) {
PatientSex = "Male";
}
if (FemaleRadioButton.isSelected()) {
PatientSex = "Female";
}
s.setSex(PatientSex);
s.setPhone(PhoneTextField.getText());
ArrayList<PatientCondition> PatientConditions3 = new ArrayList();
===> PatientConditions3 = (ArrayList<PatientCondition>) ConditionsJList.getSelectedValuesList(); //error here
s.setConditionsList(PatientConditions3);
PatientInfoLabel2.setText("Patient Details Updated");
for (Patient f : PatientList) {
PatientListModel.addElement(f.getAccountNumber() + "-" + f.getName());
}
PatientJList.setModel(PatientListModel);
UpdateAllViews();
//
}
}
}
错误是:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.util.Collections$EmptyList cannot be cast to java.util.ArrayList