I have a problem with my ComboBox, the issue is that when i add a Item it not show this item on the ComboBox.
package gui.components;
import javax.swing.JComboBox;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import gui.SubjectList;
public class SubjectBox extends JComboBox<String> implements ChangeListener {
SubjectList subjectList;
PointPane pointPane;
public SubjectBox(SubjectList subjectList, PointPane pointPane) {
this.subjectList = subjectList;
this.pointPane = pointPane;
setBounds(1020, 530, 160, 29);
}
public void updateList() {
removeAllItems();
for (int x = 0; x > subjectList.getSubjects().size(); x++) {
addItem(subjectList.getSubjects().get(x).getName());
}
pointPane.updateList();
}
@Override
public void stateChanged(ChangeEvent event) {
pointPane.updateList();
}
}
Your first guess would be maybe: "for-loop not gets executed, because subjectList.getSubjects().size() may be 0 or some"
- Already tested with a s.o.p if it gets executed, and yes it do
Your second guess would be maybe: "subjectList.getSubjects().get(x).getName() is ""(nothing) and this is why it not show anything"
- Already tested by just addItem("Test") instate of the name from list, and yes it do not work eather
(I would be very happy on response because its a homework and it would be nice to finish today)