[英]remove focus from JTable first row
I have JTable and rows in it. 我有JTable和行。 By default first row is selected and focus is in it.
默认情况下,第一行被选中并且焦点在其中。 How can I deselect first row and change focus to somewhere else that
.addListener(new RowSetListener()
will work in first row too. 如何取消选择第一行并将焦点更改为
.addListener(new RowSetListener()
也将在第一行中工作的其他位置。
I already try: 我已经尝试过:
tableZaposlenciView1.setRowSelectionAllowed(true);
//tableZaposlenciView1.getSelectionModel().clearSelection();
//tableZaposlenciView1.setColumnSelectionInterval(0,0);
//tableZaposlenciView1.setRowSelectionInterval(false,false);
tableZaposlenciView1.changeSelection(0,0,false,false);
tableZaposlenciView1.requestFocus();
but it is not working. 但它不起作用。
Have a look at JTable's changeSelection() method. 看看JTable的changeSelection()方法。 I believe it does what you want.
我相信它能做到你想要的。
EDIT: If you want to clear the selection: 编辑:如果要清除选择:
JTable table = ...;
table.getSelectionModel().clearSelection();
if someone else have similar problem with ADF and JTable here is solution. 如果其他人有与ADF和JTable类似的问题,这里是解决方案。 I achieve that by overriding first() on the VO impl.
我通过覆盖VO impl上的first()实现了这一点。 my problem can be solved.
我的问题可以解决。
That comes in handy in many situations: 这在许多情况下派上用场:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.