简体   繁体   中英

Can a table row be unselected after it has been selected?

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

Background:

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?

tblRestoTable.getSelectionModel().clearSelection();

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM