I have a TableView for which the base item is a custom class i.e. TableAdapter.
I am creating a ContextMenu in a custom cell factory for TableCells. In the EventHandler for the menu item, I need to access the underlying TableAdapter represented by the specific cell where the menu shows. If I call getItem() or getString() they both seems to return a String representation of the object, however, I need the object itself to access other fields. Thanks,
private final class cCustomTableCell extends TableCell
{
private ContextMenu menu = new ContextMenu();
public cCustomTableCell(){
MenuItem menuItem = new MenuItem("Show in tree");
menu.getItems().add(menuItem);
menuItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
// THIS IS WHERE I NEED TO ACCESS THE UNDERLYING OBJECT
}
});
setContextMenu(menu);
}
Try to define the generic type. for example:
The
getItem()should return Boolean in that case