0% found this document useful (0 votes)
12 views

4 Java Module5 Menu

The document discusses JavaFX menus. It explains that the Menu class is used to implement menus in JavaFX applications. It provides examples of how to create a menu bar, add menus to it, and add menu items to the menus. Key methods for working with menus like getItems(), hide(), show(), getMenus() are also described along with their purposes.

Uploaded by

suyash agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

4 Java Module5 Menu

The document discusses JavaFX menus. It explains that the Menu class is used to implement menus in JavaFX applications. It provides examples of how to create a menu bar, add menus to it, and add menu items to the menus. Key methods for working with menus like getItems(), hide(), show(), getMenus() are also described along with their purposes.

Uploaded by

suyash agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CSE1007 - JAVA PROGRAMMING

MODULE-5
JavaFX Menu
JavaFX Menu
• JavaFX provides a Menu class to implement
menus.
• Menu is the main component of any application.
• In JavaFX, javafx.scene.control.Menu class
provides all the methods to deal with menus.
• This class needs to be instantiated to create a
Menu.
JavaFX Menu
//creating MenuBar
ManuBar menubar = new MenuBar();
//creating Menu
Menu MenuName = new Menu("Menu Name");
//creating Menu Item
MenuItem MenuItem1 = new MenuItem("Menu Item 1 Name");
//adding Menu Item to the Menu
MenuName.getItems().add(MenuItem1);
//adding Menu to the MenuBar
menubar.getMenus().add(MenuName);
JavaFX Menu
Method Explanation
getItems() returns the items of the menu
hide() hide the menu
show() show the menu
getMenus() The menus to show within this MenuBar.
Gets the value of the property
isUseSystemMenuBar()
useSystemMenuBar
Sets the value of the property
setUseSystemMenuBar(boolean v)
useSystemMenuBar.
setOnHidden(EventHandler v) Sets the value of the property onHidden.
setOnHiding(EventHandler v) Sets the value of the property onHiding.
setOnShowing(EventHandler v) Sets the value of the property onShowing.
setOnShown(EventHandler v Sets the value of the property onShown.
Example

You might also like