Caused by: java.lang.RuntimeException: A bound value cannot be set.
at javafx.scene.control.TextInputControl$TextProperty.set(TextInputControl.java:971)
at javafx.scene.control.TextInputControl.setText(TextInputControl.java:193)
//code
@Override
public void start(Stage stage) throws Exception {
final ComboBox cb = new ComboBox();
final TextField tf = new TextField();
cb.setEditable(true);
Button btnBind = new Button("1. Bind text field");
btnBind.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
cb.getEditor().textProperty().bind(tf.textProperty());
}
});
Button btn = new Button("2. Set value");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
cb.setValue(1);
}
});
VBox vb = new VBox(10.);
vb.getChildren().addAll(cb, tf, btnBind, btn);
Scene scene = new Scene(vb, 200, 300);
stage.setTitle("Bug");
stage.setScene(scene);
stage.show();
}
click button 1. Bind text field
type any text in text field
click button 2. Set value
at javafx.scene.control.TextInputControl$TextProperty.set(TextInputControl.java:971)
at javafx.scene.control.TextInputControl.setText(TextInputControl.java:193)
//code
@Override
public void start(Stage stage) throws Exception {
final ComboBox cb = new ComboBox();
final TextField tf = new TextField();
cb.setEditable(true);
Button btnBind = new Button("1. Bind text field");
btnBind.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
cb.getEditor().textProperty().bind(tf.textProperty());
}
});
Button btn = new Button("2. Set value");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
cb.setValue(1);
}
});
VBox vb = new VBox(10.);
vb.getChildren().addAll(cb, tf, btnBind, btn);
Scene scene = new Scene(vb, 200, 300);
stage.setTitle("Bug");
stage.setScene(scene);
stage.show();
}
click button 1. Bind text field
type any text in text field
click button 2. Set value