0

我遇到的问题是当我试图通过创建一个方法并调用该方法从表中查找数据时。似乎该表不存在,因为我得到一个ArrayIndexOutOfBoundsException.

下面是代码,模型是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);
}
4

1 回答 1

2

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.

于 2012-02-18T23:33:49.733 回答