2

我想知道用户(不是以编程方式!)是否可以完全取消选择 JavaFX 2TableView表行,一旦它被选中?

背景:

我向 a 的 selectedProperty 添加了一个更改侦听器,TableView我想知道提供给更改侦听器的新值是否可以为空?

4

2 回答 2

6
tblRestoTable.getSelectionModel().clearSelection();
于 2013-04-19T03:32:50.663 回答
1

I am wondering if a user (not programmatically!) can completely unselect a JavaFX 2 TableView table row, once it was selected?

I don't think so, at least not in JavaFX 2.2.

I added a change listener to the selectedProperty of a TableView and I am wondering if the new value provided to the change listener can ever be null?

Probably safest to place a null check in your change listener in any case in case the selection gets cleared programmatically as for example in amru's solution or in case in some future JavaFX version the ability for a user to deselect the last selected row in the table is added to the platform.

于 2013-04-19T07:31:11.277 回答