table.setRowSelectionInterval(0, 0);
我试过上面的代码,但是当我使用这段代码时,我无法使用下面的代码检索值:
int col = table.getSelectedColumn();
int row = table.getSelectedRow();
finalOID=(String)table.getModel().getValueAt(row, col);
System.out.println("first oid:"+finalOID);
我该如何解决这个问题?
最佳答案
查看 JTable 的方法
table.changeSelection(0, 0, false, false);
取决于 Selection Mode
方法必须在 Event Dispatch Thread
上调用,更多内容在 Oracle 教程中 Concurency in Swing
关于java - 将 jtable 中的第一行保留为默认选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11862108/