I have seen several posts here but none of them answers my question. I am using scene builder so I couldn't figure out how to get access to individual row. I only need to update observable list to update my table contents. So I don't exactly add every row individually. Also my table is going to have about 10000+ entries so adding listener to every individual row will be resource heavy. So I need to put it only a single listener and figure out which row is clicked? is it a double click? and make sure row is not empty. Please help. Thanks in advance.
Asked
Active
Viewed 689 times
0
-
There's no way to do this directly in FXML, you must do it in your controller class. Also, note that in the linked question you add the listener to every `TableRow`, not every table *item*. So, unless you have a screen that is about 200 feet high, you are not creating 10,000 listeners. (Listeners are very lightweight objects anyway, so even if you were, I'm not convinced it would be an issue.) – James_D Oct 09 '15 at 19:33
-
I do not want to do it in my fxml file of course. It will be in the controller. I could not find a way to add a single listener once and get the information about which row is double clicked. All other answers shows that 'row.addlistener(..' option which is not the case here. Also even if I decide to use that approach how do I access rows? I never create a single row I just update my observablelist and 'tableview' is automatically updated. – Rohit S Oct 10 '15 at 07:16
-
The solution to this problem is not to use a single listener but to use a listener for each `TableRow`, as shown in the answer to the question I linked. The way to access the `TableRow`s is via a `rowFactory`, which you set on your `TableView`, as shown in the answer to the question I linked. – James_D Oct 10 '15 at 12:17