如何以编程方式取消选择JTable(swing)中当前选定的行? [英] How to programmatically deselect the currently selected row in a JTable (swing)?
本文介绍了如何以编程方式取消选择JTable(swing)中当前选定的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以编程方式取消选择JTable中当前选定的一行(或多行)。
I want to programmatically deselect the currently selected row (or rows) in a JTable.
基本上我想要与此相反:
Basically I want the opposite of this:
JTable table = ...;
table.setRowSelectionInterval(x,x);
我试过(没什么希望)使用:
I tried (with little hope) using:
table.setRowSelectionInterval(-1,-1)
或
table.setRowSelectionInterval(1,0)
但它不起作用。
推荐答案
有一个方法 JTable
名为 clearSelection
。这反过来在表和列模型的 ListSelectionModel
上调用 clearSelection
。
There is a method on JTable
called clearSelection
. This, in turn calls clearSelection
on the ListSelectionModel
of the table and the column model.
这篇关于如何以编程方式取消选择JTable(swing)中当前选定的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文