JavaFX Tutorial - Menu, Sub Menu, Custom Menus

Опубликовано: 11 Март 2025
на канале: Noble Code Monkeys
3,200
32

This tutorial will discuss the built in JavaFX Menu Bar. On the surface this might not seem like a large topic, but there is actually a lot you can do with the Menu in JavaFX. We’ll go over:

Creating a Menu Bar with menu items
Adding icons/images to the menu options
Creating sub menus
Creating grouped radio menu items
Creating separators
Creating custom menu items
Handling menu item clicks

I'll demonstrate everything in the FXML first, and then towards the end of the video we'll look at creating the menu in the controller.

I tend to do as much as possible in the FXML. Even if you use the SceneBuilder to create your JavaFX GUI it is important to understand what is happening behind the scenes.

Strangely, I still see people manually creating menus. This is not only time consuming but unnecessary.

The built in Menu Bar looks nice, and is easy to create.