-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u5
-
Java 8u5 on Mac OS X 10.7.5 on Macbook Air; colleague gets same behaviour on 8u5 on Macbook Pro with Mavericks.
I have an existing application that I am progressively adding JavaFX to. I have a Stage that I make with a menu, and I call setUseSystemMenuBar(true). However, on Mac this has no effect. I wonder if this could be fixed if possible, or if is intended behaviour that it does not work, if that could be documented somewhere. Steps to reproduce:
// A class that creates a scene with a menu and sets useSystemMenuBar to true:
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.VBox;
public class MenuScene extends Scene
{
public MenuScene()
{
super(new VBox());
MenuBar m = new MenuBar();
Menu menu = new Menu("My Menu");
menu.getItems().add(new MenuItem("My item"));
m.getMenus().add(menu);
m.setUseSystemMenuBar(true);
((VBox)getRoot()).getChildren().addAll(m, new Label("Content"));
}
}
// It works if I call it from a JavaFX Application:
import javafx.application.Application;
import javafx.stage.Stage;
public class TestPureMenu extends Application
{
@Override
public void start(Stage stage) throws Exception
{
stage.setScene(new MenuScene());
stage.show();
}
}
// But not if I call it from an existing non-JavaFX application:
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.stage.Stage;
public class TestEmbedMenu
{
public static void main(String[] args) {
// Initialise JavaFX:
new JFXPanel();
// Now make Stage:
Platform.runLater(() -> {
Stage s = new Stage();
s.setScene(new MenuScene());
s.show();
});
}
}
// A class that creates a scene with a menu and sets useSystemMenuBar to true:
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.VBox;
public class MenuScene extends Scene
{
public MenuScene()
{
super(new VBox());
MenuBar m = new MenuBar();
Menu menu = new Menu("My Menu");
menu.getItems().add(new MenuItem("My item"));
m.getMenus().add(menu);
m.setUseSystemMenuBar(true);
((VBox)getRoot()).getChildren().addAll(m, new Label("Content"));
}
}
// It works if I call it from a JavaFX Application:
import javafx.application.Application;
import javafx.stage.Stage;
public class TestPureMenu extends Application
{
@Override
public void start(Stage stage) throws Exception
{
stage.setScene(new MenuScene());
stage.show();
}
}
// But not if I call it from an existing non-JavaFX application:
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.stage.Stage;
public class TestEmbedMenu
{
public static void main(String[] args) {
// Initialise JavaFX:
new JFXPanel();
// Now make Stage:
Platform.runLater(() -> {
Stage s = new Stage();
s.setScene(new MenuScene());
s.show();
});
}
}
- relates to
-
JDK-8096313 [JFXPanel] Swing and JavaFX menus appear together in menu bar on Mac OS X
- Closed