gpt4 book ai didi

java - 尝试在方法中从 Jtable 中提取数据,但一无所获

转载 作者:行者123 更新时间:2023-12-02 07:58:08 25 4
gpt4 key购买 nike

我遇到的问题是当我尝试通过创建一个方法并调用该方法来从表中查找数据时。该表似乎不存在,因为我收到 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);
}

最佳答案

没有足够的信息来确定,但似乎 ActionListenerTableModel之前被调用已全面建成。另外,验证所有 Swing 组件是否仅在 event dispatch thread 上构建和操作。 .

关于java - 尝试在方法中从 Jtable 中提取数据,但一无所获,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9343096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com