Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TableView Remove Item Error

v2cg4ss-JavaNetJan 23 2013 — edited Jan 23 2013
I am removing selected items from a table view, the table view is a list of maps since my columns are dynamic based on a sql query. I perform the following code the number of rows removed from the table view is not what I expect. I highlight 2 rows and only one is removed when Method 1 is executed, I noticed in the debugger for every item removed from the table view getItems remove method, 2 items are removed from the selected items. When I execute Method 2, then ALL of the items are removed from the table view.

I'm using the JDK 7 update 10.

Method 1:

List<Map> items = tblViewDSResults.getSelectionModel().getSelectedItems();

boolean removed = true;
for (Map item : items)
{
removed = tblViewDSResults.getItems().remove(item);
}

Method 2:

tblViewDSResults.getItems().removeAll(tblViewDSResults.getSelectionModel().getSelectedItems());
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 20 2013
Added on Jan 23 2013
3 comments
348 views