Update Buttons JavaFX when a selected process in TableView ends -
i want disable/enable buttons under borderpane when process in selected row ends.
i try this
downloadtable.getselectionmodel().getselectedindices().addlistener(new listchangelistener<integer>() { @override public void onchanged(change<? extends integer> c) { int selectedindex = downloadtable.getselectionmodel().getselectedindex(); if (downloadtable.getitems().get(selectedindex).getstatus() == download.downloading) { cancelbutton.setdisable(false); } else { cancelbutton.setdisable(true); } } });
but works if switch items (download) ended. want enable/disable buttons while item selected. all
maybe can you:
public class main { private button somebutton; private tableview<?> downloadtable; private void somemethod() { //somecode callback<tableview<?>, tablerow<?>> basefactory = downloadtable.getrowfactory(); downloadtable.setrowfactory( new customrowfactory<?>( somebutton, basefactory ) ); //somecode } } public class customrowfactory<t> implements callback<tableview<t>, tablerow<t>> { private final callback<tableview<t>, tablerow<t>> basefactory; private final button somebutton; public custromrowfactory( button somebutton, callback<tableview<t>, tablerow<t>> basefactory) { this.somebutton = sombutton; this.basefactory = basefactory; } @override public tablerow<t> call(tableview<t> tableview) { final tablerow<t> row = basefactory == null ? row = new tablerow<>() : row = basefactory.call( tableview ); somebutton.disableproperty().bind( row.selectedproperty().and( row.getitem().statusproperty().isnotequals(download.downloading) ) ); return row; } }
or insert binding in of tablecell
implementation.
Comments
Post a Comment