Description
Sample to reproduce:
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
VBox root = new VBox();
@Override
public void start(final Stage stage) throws Exception {
Scene scene = new Scene(root, 300, 300);
final Label label = new Label("_Label");
label.setMnemonicParsing(true);
final Button button1 = new Button("Button1");
final Button button2 = new Button("Button2");
ToggleGroup group = new ToggleGroup();
RadioButton rb1 = new RadioButton("setLabelFor(button1)");
rb1.setToggleGroup(group);
rb1.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
if (t1) {
label.setLabelFor(button1);
}
}
});
RadioButton rb2 = new RadioButton("setLabelFor(button2)");
rb2.setToggleGroup(group);
rb2.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
if (t1) {
label.setLabelFor(button2);
}
}
});
root.getChildren().addAll(label, button1, button2, rb1, rb2);
stage.setScene(scene);
stage.show();
}
}
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
VBox root = new VBox();
@Override
public void start(final Stage stage) throws Exception {
Scene scene = new Scene(root, 300, 300);
final Label label = new Label("_Label");
label.setMnemonicParsing(true);
final Button button1 = new Button("Button1");
final Button button2 = new Button("Button2");
ToggleGroup group = new ToggleGroup();
RadioButton rb1 = new RadioButton("setLabelFor(button1)");
rb1.setToggleGroup(group);
rb1.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
if (t1) {
label.setLabelFor(button1);
}
}
});
RadioButton rb2 = new RadioButton("setLabelFor(button2)");
rb2.setToggleGroup(group);
rb2.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
if (t1) {
label.setLabelFor(button2);
}
}
});
root.getChildren().addAll(label, button1, button2, rb1, rb2);
stage.setScene(scene);
stage.show();
}
}
Attachments
Issue Links
- relates to
-
JDK-8124562 Mnemonics issue : changing setLabelFor() target fails
-
- Resolved
-