6 Replies Latest reply: Jun 27, 2012 2:51 PM by 921851 RSS

    Javafx 2.1: useSystemMenuBar issues (Mac)

    921851
      Hi All,

      Recently I moved everything related to the project I'm developing from windows to mac, but I'm having some problems, two actually, using the useSystemMenuBar

      The first one is less critical, a "java" menu appears left sided with my first menu item. I tried and looked how to solve this by googling but it's not like there are tons of javafx 2 mac developers out there.

      The second one is a critical one though, whenever I activate one of my windows the menu bar hides and again, only the "java" menu item appears on the mac menu bar. Here's the code which I initialize the menu bar:


      @Override
           public void start(Stage stage) throws Exception
           {
                primaryStage = StageHandler.getStage();
                MenuBar menuBar = FXMLLoader.load(getClass().getResource("/fxml/MainWindow.fxml"), Resources.getBundle("bundle.MainWindow"));
                
                if(System.getProperty("os.name").indexOf("Mac")>=0)
                {
                     menuBar.setUseSystemMenuBar(true);
                     primaryStage.getIcons().add(new Image(getClass().getResource("/icons/logo.png").toString()));
                     primaryStage.setTitle("Netuno");
                     Scene scene = new Scene(menuBar, WIDTH, HEIGHT, Color.TRANSPARENT);
                     primaryStage.setScene(scene);
                     primaryStage.show();
                }
                else
                {
                     menuBar.setUseSystemMenuBar(false);
                     
                     HBox hbox = new HBox();
                     hbox.setAlignment(Pos.CENTER);
                     hbox.getChildren().add(menuBar);
                     TronBox root = new TronBox(WIDTH, HEIGHT, false);
                     root.addFrameChildren(hbox);
                     
                     primaryStage.getIcons().add(new Image(getClass().getResource("/icons/logo.png").toString()));
                     primaryStage.setTitle("Netuno");
                     primaryStage.setIconified(false);
                     primaryStage.setY(0);
                     primaryStage.focusedProperty().addListener(changeListener);
                     
                     final Popup popup = getAlwaysOnTop(root);
                     primaryStage.getScene().getStylesheets().clear();
                     primaryStage.getScene().getStylesheets().add(getClass().getResource("/css/MainWindow.css").toString());
                     popup.show(primaryStage);
                }
                
           }