Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8116639

Mnemonic isn't shown when textProperty is bound.


    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.1
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Labels:
    • Environment:

      2.1 b12


      I have a localized application with different texts bound to controls. I noticed that, when I switch the locale the mnemonics are no longer displayed.

      To see it, run the code below.
      Open the Menu, press ALT, see that it works. (the button and the menu item have an underscore under the mnemonic).

      The press the toggle button to trigger a text change.

      Open the Menu, press ALT, see that it is not underlined. Also note, the button isn't underlined, too.

      It still works (press ALT D, see console output), but it is not displayed to the user.

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TestApp3 extends Application {
          public static void main(String[] args) throws Exception {

          public void start(final Stage stage) throws Exception {

              VBox root = new VBox();

              MenuBar menuBar = new MenuBar();
              Menu menu = new Menu("_Menu");


              MenuItem menuItem = new MenuItem();
              menuItem.setOnAction(new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent actionEvent) {
                      System.out.println("MenuItem action");

              final ToggleButton button = new ToggleButton("Toggle language");
              button.setOnAction(new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent actionEvent) {
                      if (button.isSelected()) {
                          menuItemLabel.set("_DE Item");
                          buttonLabel.set("_FR Button");
                      } else {
                          menuItemLabel.set("_EN Item");
                          buttonLabel.set("_IT Button");

              Button localizedButton = new Button();

              root.getChildren().addAll(menuBar, localizedButton, button);
              Scene scene = new Scene(root);

          private StringProperty menuItemLabel = new SimpleStringProperty("_EN Item");

          private StringProperty buttonLabel = new SimpleStringProperty("_IT Button");




            • Assignee:
              leifs Leif Samuelsson (Inactive)
              cschudtjfx Christian Schudt (Inactive)
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: