Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Stage puts App menu on it #19

Open
EasyG0ing1 opened this issue Sep 25, 2022 · 2 comments
Open

New Stage puts App menu on it #19

EasyG0ing1 opened this issue Sep 25, 2022 · 2 comments

Comments

@EasyG0ing1
Copy link

EasyG0ing1 commented Sep 25, 2022

Just started trying to implement this library into an app of mine, and I got it properly showing the menu at the top of the screen in MacOs, but when I create new scenes (with new stages) they get a copy of the menu placed on them as you can see in the attached screen shot.

How do I prevent this from happening?

Screen Shot 2022-09-25 at 11 55 41 AM

@Oliver-Loeffler
Copy link

Oliver-Loeffler commented Oct 22, 2022

For each MenuBar, it might be required to set the property useSystemMenuBar to true.
This can be achieved using recent versions of Scene Builder or manually in the FXML.

Do the new Scenes and Stages also have their own menus?

Bildschirmfoto 2022-10-22 um 20 18 27

The FXML looks as follows:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <MenuBar prefHeight="11.0" prefWidth="140.0" useSystemMenuBar="true">
        <menus>
          <Menu mnemonicParsing="false" text="File">
            <items>
              <MenuItem mnemonicParsing="false" text="Close" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Edit">
            <items>
              <MenuItem mnemonicParsing="false" text="Delete" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Help">
            <items>
              <MenuItem mnemonicParsing="false" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
   </children>
</AnchorPane>

In Java code its:

MenuBar menuBar = new MenuBar();
menuBar.useSystemMenuBarProperty().setValue(true);

@EasyG0ing1
Copy link
Author

@Oliver-Loeffler Sorry I didn't catch that you commented on here till today.

To answer your question, NO, those other windows do not have any menu on them at all, and I don't use FXML ... I stopped using it years ago. So for example, the screenshot I showed you normally looks like this:

Screenshot 2023-01-26 at 11 55 26 AM

But when I use your library, it throws a menu on every Scene for some reason. I only have one window with a menu and everything else is dialogue style only built manually with standard Scenes and Stages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants