Closed dlemmermann closed 2 years ago
If you use the addMenuItem(javafx.scene.control.MenuItem)
API, it always inserts at the end of the menu item list. But, there is also a insertMenuItem(javafx.scene.control.MenuItem, int)
to insert at a menu item at a certain position.
Closing, considering the comment made by @dwalluck
I will consider implementing an index setting for the "Exit" item in future releases, though if you wanted to create your own custom "Exit" item, it simply calls Platform.setImplicitExit(true); Platform.exit();
@dlemmermann - There is already a Builder method for automatically adding an Exit menu to the bottom of the trayIcon - note the .addExitMenuItem() in this build sentence:
trayIcon = new FXTrayIcon.Builder(stage, getClass().getResource("FXIconRedYellow.png"))
.toolTip("An alternative tooltip!")
.menuItem(menuItemTest)
.menuItem(menuOptions)
.applicationTitle("FXTrayIcon Builder Text")
.separator()
.addExitMenuItem()
.build();
I'm going to add the option of setting the label as desired in my next PR.
Maybe he wants additional methods that add a position index parameter, but I guess a builder is meant to only be called once and it adds the menus in called order.
@dwalluck The Builder does add the menuItems in the order that they are inserted into the build sentence. But the exitMenu can be added anywhere in the build sentence and it will always get placed at the bottom of the menu.
I also think that some kind of an indexing structure would be handy, I might start a new issue on that topic to open it up for some discussion as to how that should look from a usability perspective. I've got some ideas but it's always nice to get everyone's input on that kind of thing.
Is there a reason why menus are always placed at the bottom of the menu. I now have a menu with four to five menu items, then the "exit" item, then the menus with subitems. How can I get the exit item to be all the way at the bottom?