JavaFX disable button -


i'm writing program in netbeans javafx view has several buttons in bad buttons(like bombs minesweeper), i'm trying freeze program when bad button pushed don't find how it

thanks!

there various solutions problem. 2 among them ignoring action event or disabling buttons this:

public class buttonaction extends application {      final booleanproperty buttonactionproperty = new simplebooleanproperty();      public static void main(string[] args) {         application.launch(args);     }      @override     public void start(stage primarystage) {          flowpane root = new flowpane();          checkbox checkbox = new checkbox( "enabled");         checkbox.setselected(true);          // solution 1: check if action allowed , process or not         buttonactionproperty.bind( checkbox.selectedproperty());          button button = new button( "click me");         button.setonaction(e -> {             if( buttonactionproperty.get()) {                 system.out.println( "allowed, processing action");             } else {                 system.out.println( "not allowed, no action");             }         });          // solution 2: remove comments activate code         // button.disableproperty().bind(buttonactionproperty.not());          root.getchildren().addall(checkbox, button);          primarystage.setscene(new scene(root, 600, 200));         primarystage.show();      } } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -