Steve
Steve

Reputation: 4691

FXML CustomMenuItem Example

I'm having a hard time finding an example of a CustomMenuItem in FXML. Based on the API docs, I was trying this:

<SplitMenuButton fx:id="dwnldBtn" text="Download"
    maxWidth="10000" maxHeight="10000" prefHeight="10000"
    GridPane.columnIndex="0" GridPane.rowIndex="3" onAction="#handleDownloadBtn">
    <items>
        <CustomMenuItem  >
            <button text="Download All" onAction="#handleDownloadAllBtn"/>
        </CustomMenuItem>
    </items>
</SplitMenuButton>

But it seems this is syntactically wrong. I want to use a button within a CustomMenuItem, because (unlike a regular MenuItem) a button can be resized (MenuItem lacks properties like maxWidth).

Upvotes: 1

Views: 331

Answers (1)

James_D
James_D

Reputation: 209418

See Javadocs. CustomMenuItem has a property called content that determines the node displayed in the menu item.

<CustomMenuItem>
    <content>
        <Button text="..." onAction="#..."/>
    </content>
</CustomMenuItem>

Upvotes: 2

Related Questions