Example usage for javafx.scene.control Menu getItems

List of usage examples for javafx.scene.control Menu getItems

Introduction

In this page you can find the example usage for javafx.scene.control Menu getItems.

Prototype

public final ObservableList<MenuItem> getItems() 

Source Link

Document

The items to show within this menu.

Usage

From source file:net.gazeplay.commons.utils.games.Utils.java

public static MenuBar buildLicence() {
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    String licenseFileAsString = loadLicenseFileAsString(classLoader);

    MenuItem licenseMenuItem = new MenuItem(licenseFileAsString);

    Menu menu = new Menu("GazePlay");
    menu.getItems().add(licenseMenuItem);

    MenuBar menuBar = new MenuBar();
    menuBar.getMenus().addAll(menu);//from   ww w  .  j ava2  s. c o  m
    menuBar.setPrefHeight(40);
    menuBar.setPrefWidth(80);

    return menuBar;
}

From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java

public static void updateScriptList(final List<Script> scripts, final Menu scriptsMenu,
        final ToggleGroup toggleGroup, final String format, final EventHandler<ActionEvent> eventHandler) {
    while (scriptsMenu.getItems().size() > 0) {
        scriptsMenu.getItems().remove(0);
    }/*from ww  w . ja  va 2  s. c om*/

    if (scripts.size() > 0) {
        for (final Script script : scripts) {
            final RadioMenuItem item = new RadioMenuItem(String.format(format, script.getName()));
            item.setOnAction(eventHandler);
            item.setToggleGroup(toggleGroup);
            item.setUserData(script);

            scriptsMenu.getItems().add(item);
        }
    }
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Menus");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();

    Menu menu = new Menu("File");
    menu.getItems().add(new MenuItem("New"));
    menu.getItems().add(new MenuItem("Save"));
    menu.getItems().add(new SeparatorMenuItem());
    menu.getItems().add(new MenuItem("Exit"));

    menuBar.getMenus().add(menu);/*www  .  java 2  s.c  o m*/

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    root.getChildren().add(menuBar);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Menus");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();

    Menu tools = new Menu("Your Menu");
    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 1").selected(true).build());

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);//from   w ww. j av a 2 s. c  om

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    root.getChildren().add(menuBar);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Menus");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();

    Menu menu = new Menu("File");
    menu.getItems().add(new MenuItem("New"));
    menu.getItems().add(new MenuItem("Save"));
    menu.getItems().add(new SeparatorMenuItem());
    menu.getItems().add(new MenuItem("Exit"));

    CustomMenuItem customMenuItem = new CustomMenuItem(new Slider());
    customMenuItem.setHideOnClick(false);
    menu.getItems().add(customMenuItem);

    menuBar.getMenus().add(menu);//from w ww .j a v  a  2 s  .co m

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    root.getChildren().add(menuBar);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Menus");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();

    Menu menu = new Menu("Item");

    Menu contingencyPlans = new Menu("Submenu");
    contingencyPlans.getItems().add(new CheckMenuItem("Item 1"));
    contingencyPlans.getItems().add(new CheckMenuItem("Item 2"));
    contingencyPlans.getItems().add(new CheckMenuItem("Item 3"));

    menu.getItems().add(contingencyPlans);

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
    menuBar.getMenus().add(menu);//from   w  w w  .j a v a  2s.co  m

    root.getChildren().add(menuBar);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
    root.setTop(menuBar);/*from   w  w w. j a  v a 2s  . com*/

    Menu fileMenu = new Menu("File");
    MenuItem exitMenuItem = new MenuItem("Exit");
    fileMenu.getItems().add(exitMenuItem);
    exitMenuItem.setOnAction(actionEvent -> Platform.exit());

    menuBar.getMenus().addAll(fileMenu);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Menus");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();

    Menu menu = new Menu("File");
    MenuItem newItem = new MenuItem("New");
    menu.getItems().add(newItem);
    menu.getItems().add(new MenuItem("Save"));
    menu.getItems().add(new SeparatorMenuItem());
    menu.getItems().add(new MenuItem("Exit"));

    newItem.setVisible(false);// ww  w .  j a  v  a 2s .  co m

    menuBar.getMenus().add(menu);

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    root.getChildren().add(menuBar);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

private Menu alarmMenu() {
    Menu alarmMenu = new Menu("Alarm");
    RadioMenuItem soundAlarmItem = new RadioMenuItem("Sound Alarm");
    RadioMenuItem stopAlarmItem = new RadioMenuItem("Alarm Off");

    Menu contingencyPlans = new Menu("Plans");
    contingencyPlans.getItems().addAll(new CheckMenuItem("A"), new CheckMenuItem("B"), new CheckMenuItem("C"));
    alarmMenu.getItems().add(contingencyPlans);
    ToggleGroup tGroup = new ToggleGroup();
    soundAlarmItem.setToggleGroup(tGroup);
    stopAlarmItem.setToggleGroup(tGroup);
    stopAlarmItem.setSelected(true);/* w  w  w  . ja va 2 s .c  o m*/
    alarmMenu.getItems().addAll(soundAlarmItem, stopAlarmItem, new SeparatorMenuItem());
    return alarmMenu;
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Menus");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();

    Menu tools = new Menu("Your Menu");
    CheckMenuItem item = new CheckMenuItem("Item 1");

    tools.getItems().add(item);

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);/*  w  w  w.j a  v a 2s .c  o m*/

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    root.getChildren().add(menuBar);
    primaryStage.setScene(scene);
    primaryStage.show();
}