Reputation: 173
How do I add sub-headers to my menu using JavaFX and the fxml files? I have looked at the CustomMenuItem option but I am unable to figure out what to put in the content part. Thanks for your help!
My fxml file:
<?import javafx.scene.input.*?>
<?import javafx.scene.control.*?>
<MenuBar>
<menus>
<Menu text="Menu 1">
<items>
<MenuItem text="Item 1" />
<MenuItem text="Item 2" />
<MenuItem text="Item 3" />
<SeparatorMenuItem />
<MenuItem text="Item A" />
<MenuItem text="Item B" />
<MenuItem text="Item C" />
</items>
</Menu>
</menus>
</MenuBar>
Below is an example of the result I am looking for. "Header 1" and "Header 2" shouldn't be clickable and should not highlight when the mouse moves over them.
Upvotes: 1
Views: 1363
Reputation: 173
Thanks for your input. Based on the link you provided, I found that it simply can be done adding the following in the fxml file:
<SeparatorMenuItem>
<content>
<Text text="Header Name" styleClass="textSeparator" />
</content>
</SeparatorMenuItem>
Upvotes: 1
Reputation: 521
I think the answer you're looking for is here:
http://tiwulfx.panemu.com/2013/01/02/creating-custom-menu-separator-in-javafx/
Upvotes: 0