javafx 2 - How to keep a TableView's selection when focus is lost? -
how can keep tableview's selection when focus lost windows?
when focus window lost, selected item still visibly selected in window; however, cannot find way access selected object controllers.
i have tried using tableview's methods getselectionmodel().selecteditemproperty().get() , getselectionmodel().getselecteditem() both of these return null if focus window and/or table lost.
use variable , set in change listener. use labels debugging.
table.getselectionmodel().getselectedcells().addlistener(new listchangelistener<tableposition>() { @override public void onchanged(listchangelistener.change<? extends tableposition> c) { label1.settext(string.valueof(c.getlist().get(0).getrow())); } }); java 8
table.getselectionmodel().getselectedcells().addlistener((listchangelistener.change<? extends tableposition> c) -> { label1.settext(string.valueof(c.getlist().get(0).getrow())); });
Comments
Post a Comment