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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.