Reputation: 59
The problem I am having is when I am trying to find data from the table by making a method and calling that method. It seems that the table doesn't exist, as I am getting an ArrayIndexOutOfBoundsException
.
Below is the code, model is the tableModel
.
// @Override
public void actionPerformed(ActionEvent arg0) {
String s = dropDown.getSelectedItem().toString();
if(s.equals("9 out of 11")) {
System.out.println(model.getValueAt(1, 1));
} else {
checkScores();
}
}
});
return panel;
}
public static void checkScores(){
Object o = model.getValueAt(1, 1);
int i = ((Integer) o).intValue();
System.out.println(i);
}
Upvotes: 0
Views: 187
Reputation: 205885
There is not enough information to be certain, but it appears that the ActionListener
is being called before the TableModel
is fully constructed. Also, verify that all Swing components are being constructed and manipulated only on the event dispatch thread.
Upvotes: 2