From the course: Learning JavaFX GUI Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Include a menu

Include a menu

From the course: Learning JavaFX GUI Development

Start my 1-month free trial

Include a menu

- [Voiceover] Most applications have some type of a menu where the menu is a list of actionable items. When you select one of the menu options it often provides the user with a submenu of items to choose from. Then an action is invoked when the user makes their selection. When creating menus in JavaFX, the first thing we need to do is identify the menu bar items. For example, in Netbeans, the menu bar contains things like File, Edit, View, Navigate, et cetera. Next, we'll define a list of menu items for each of the menu bar items. In Netbeans again, under File, the first two items are new project and new file. A menu object can also contain submenus and to separate menu items, you can use a separator, from the separator menu item class. It is important to note that the menu items are not considered nodes, and therefore cannot be added directly to the scene. Instead, we add the menu bar through the get menus method. Let's look at an example. Here is the start of a program that includes…

Contents