.disableProperty() .bind( service.runningProperty()
ObjectProperty<File> file = new SimpleObjectProperty<>(); BooleanBinding fileExists = Bindings.createBooleanBinding(() -> file.get() != null && file.get().exists(), file); Button button = new Button("OK"); button.disableProperty().bind(fileExists.not());
Button button = new Button(); button.disableProperty().bind(Bindings.createBooleanBinding(queue::isEmpty, queue));
Button btn = new Button("Save"); btn.disableProperty().bind( listener1.valid.and(listener2.valid).and(listener3.valid).not());
Button button = new Button("OK"); button.disableProperty().bind(textField1Valid.not().or(textField2Valid.not()));
Button nextButton = new Button("Next"); nextButton.disableProperty().bind(canExecute.not());
upButton.disableProperty().bind(selectedIndex.lessThanOrEqualTo(0)); downButton.disableProperty().bind(Bindings.createBooleanBinding(() -> { int index = selectedIndex.get(); return index < 0 || index+1 >= tableView.getItems().size();
TextField fileInput = new TextField(); Button inputButton = new Button("Upload File"); inputButton.disableProperty().bind(Bindings.createBooleanBinding( () -> ! new File(fileInput.getText()).exists(), fileInput.textProperty())); inputButton.setOnAction(e -> { inputFile = new File(fileInput.getText()); window.close(); });
TableView<String> tableView = new TableView<>(tableData); TableColumn<String, String> column1 = new TableColumn<>(); Button button = new Button("Button"); button.disableProperty().bind(Bindings.isEmpty(tableView.getSelectionModel().getSelectedItems()));
ObjectProperty<Object> object = new SimpleObjectProperty<>(); Button button1 = new Button("create"); button1.setOnAction(ev -> object.set(new Object())); Button button2 = new Button("magic"); button2.setOnAction(ev -> object.get().hashCode()); button2.disableProperty().bind(Bindings.isNull(object));
inputButton.disableProperty().bind(Bindings.createBooleanBinding( () -> ! new File(fileInput.getText()).exists(), fileInput.textProperty()));
formatter.setValue(0); tf.setTextFormatter(formatter); btn.disableProperty().bind(IntegerExpression.integerExpression(formatter.valueProperty()).lessThan(0));
removeButton.disableProperty().bind(Bindings.size(list).isEqualTo(0));
send_text.disableProperty().bind( typebox.lengthProperty().lessThan(1));
public class Main extends Application { private ObservableQueue<String> queue = new ObservableQueue<>(new LinkedBlockingQueue<>()); @Override public void start(Stage primaryStage) { Button btn = new Button("Add to queue"); btn.setOnAction(event -> queue.add("value")); Button btn2 = new Button("Remove to queue"); btn2.setOnAction(event -> queue.remove()); Button btn3 = new Button("Button"); btn3.disableProperty().bind(Bindings.createBooleanBinding(queue::isEmpty, queue)); FlowPane root = new FlowPane(); root.getChildren().addAll(btn, btn2, btn3); primaryStage.setTitle("Hello World!"); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
button.disableProperty().bind(service.runningProperty()); service.start();
Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.disableProperty().bind(disable); btn.setOnAction(new EventHandler<ActionEvent>() {
discard.setDisable(true); save.disableProperty().bind(tf_name.dirtyProperty().or(tf_sname.dirtyProperty()).not()); discard.disableProperty().bind(tf_name.dirtyProperty().or(tf_sname.dirtyProperty()).not());
button.disableProperty().bind(task.runningProperty()); listview.itemsProperty().bind(task.valueProperty()); Thread t = new Thread(task);
final TextField textField1 = new TextField(); final TextField textField2 = new TextField(); final TextField textField3 = new TextField(); BooleanBinding bb = new BooleanBinding() { { super.bind(textField1.textProperty(), textField2.textProperty(), textField3.textProperty()); } @Override protected boolean computeValue() { return (textField1.getText().isEmpty() && textField2.getText().isEmpty() && textField3.getText().isEmpty()); } }; Button btn = new Button("Button"); btn.disableProperty().bind(bb); VBox vBox = new VBox(); vBox.getChildren().addAll(textField1, textField2, textField3, btn);