1-7. Creating Menus

Problem

You want to create standard menus in your JavaFX applications.

Solution

Employ JavaFX’s menu controls to provide standardized menuing capabilities such as check box menus, radio menus, submenus, and separators. The following are the main classes used to create menus.

  • javafx.scene.control.MenuBar
  • javafx.scene.control.Menu
  • javafx.scene.control.MenuItem

The following code calls into play all the menuing capabilities listed previously. The example code will simulate a building security application containing menu options to turn on cameras, sound an alarm, and select contingency plans.

        primaryStage.setTitle("Chapter 1-7 Creating Menus");         Group root = new Group();         Scene scene = new Scene(root, ...

Get JavaFX 2.0: Introduction by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.