-
Bug
-
Resolution: Fixed
-
P4
-
8u25
-
os_x
At least on my Mac, the titles of menus and menu items do not change if I set their text to something new. I have written the test case below, in which I create a menu titled "Wrong", and then change the title to "Correct". The test case displays "Wrong", which proves that my change is not reflected in the UI.
This bug is a problem for localized apps like mine, in which the menu item titles will change as different users with different language preferences log in.
If anyone else runs into this: You can work around this bug by rebuilding the menu every time a menu item title text changes. It is certainly not pretty, but it works.
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class MenuTest extends Application {
@Override
public void init() throws Exception {
}
@Override
public void start(Stage stage) throws Exception {
GridPane pane = new GridPane();
Scene scene = new Scene(pane);
stage.setScene(scene);
stage.setTitle("Menu bar bug test");
MenuBar menuBar = new MenuBar();
menuBar.setUseSystemMenuBar(true);
Menu menu = new Menu("Wrong");
menuBar.getMenus().add(menu);
pane.getChildren().add(menuBar);
stage.setWidth(600);
stage.setHeight(600);
stage.show();
Platform.runLater(() -> menu.setText("Correct"));
}
public static void main(String... arguments) {
launch(MenuTest.class, arguments);
}
}
This bug is a problem for localized apps like mine, in which the menu item titles will change as different users with different language preferences log in.
If anyone else runs into this: You can work around this bug by rebuilding the menu every time a menu item title text changes. It is certainly not pretty, but it works.
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class MenuTest extends Application {
@Override
public void init() throws Exception {
}
@Override
public void start(Stage stage) throws Exception {
GridPane pane = new GridPane();
Scene scene = new Scene(pane);
stage.setScene(scene);
stage.setTitle("Menu bar bug test");
MenuBar menuBar = new MenuBar();
menuBar.setUseSystemMenuBar(true);
Menu menu = new Menu("Wrong");
menuBar.getMenus().add(menu);
pane.getChildren().add(menuBar);
stage.setWidth(600);
stage.setHeight(600);
stage.show();
Platform.runLater(() -> menu.setText("Correct"));
}
public static void main(String... arguments) {
launch(MenuTest.class, arguments);
}
}