This is a part of my source (when I enter a button) of my JDilog form. I have made an object from the SystemManagement
class which is management (I have written also some part of this class). When the user add her/his information, with the addStudent()
method in SystemManagement
class I add her/his information to the student's list but when I write
System.out.println(management.getField());
It will return null! Why?
private void submit() {
String name = nameField.getText();
String family = familyField.getText();
String ye = (String) yearComboBox.getSelectedItem();
String ci = (String) cityComboBox.getSelectedItem();
String fi = (String) fieldComboBox.getSelectedItem();
if (ye == null) {
JOptionPane.showMessageDialog(this, "You haven't chosen the year of entrance", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (ci == null) {
JOptionPane.showMessageDialog(this, "You have not set the city", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (fi == null) {
JOptionPane.showMessageDialog(this, " You have not set the field", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (name.equals("")) {
JOptionPane.showMessageDialog(this, "You have not set your name ", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (family.equals("")) {
JOptionPane.showMessageDialog(this, " You have not set the family", "Error ", JOptionPane.ERROR_MESSAGE);
return;
}
management.addStudent(name, family, ye,ci, fi);
System.out.println(management.getField());
JOptionPane.showMessageDialog(this, management.toString(), " registered successefully", JOptionPane.INFORMATION_MESSAGE);
clear();
}
public class SystemManagement implements Serializable {
private String siteName;
private List<Fields> fields;
private List<Professors> professors;
private List<Students> students;
private List<Lessons> lessons;
public Professors pro;
public Lessons les;
public SystemManagement(String siteName) {
this.siteName = siteName;
professors = new ArrayList<Professors>();
students = new ArrayList<Students>();
lessons = new ArrayList<Lessons>();
fields = new ArrayList<Fields>();
}
public List<Fields> getFields() {
return fields;
}
public void setField(String field) {
this.field = field;
}
public String getField() {
return field;
}
public void addStudent(String name, String family, String yearOfEntrance, String city, String field) {
Students student = new Students(name, family, yearOfEntrance, city, field);
students.add(student);
}