问题
I have a TableView in which I have a clients emails column. In the emails column there is a Label called emails that should get populated with emails from the database depending on the column in which the Label is on.
The text is retrieved from a database and therefore, to get a specific email address, I need to get the row index, and query for that particular email with something like:
"SELECT email from Clients WHERE clientID = " + rowItemRecord.getClientID());
My approach so far is as follows:
int itemRowIndex = getTableRow().getIndex();
NewClientPOJO rowItemRecord = (NewClientPOJO) table.getItems().get(itemRowIndex);
// Then
"SELECT email from Clients WHERE clientID = " + rowItemRecord.getClientID());
This doesn't work. I get a null pointer.
The Question is:
How can I get the TableView TableRow index.... A better approach that will work.
回答1:
I assume you must first start your index: Try first wiht "if ... hasNext()" then index=... hasNext check if a value exists, and then start the index at this value. I'm not sure of the exact name of the method "hasnext", I let you find this by yourself :) Niko
来源:https://stackoverflow.com/questions/23824061/how-to-get-the-tablerow-index-javafx-tableview