Example usage for javafx.scene.control Menu Menu

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

Introduction

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

Prototype

public Menu(String text) 

Source Link

Document

Constructs a Menu and sets the display text with the specified text.

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);// ww w .  java  2 s .co m
    menuBar.setPrefHeight(40);
    menuBar.setPrefWidth(80);

    return menuBar;
}

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 w w .j  av a2  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) {
    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 ww . j a v  a  2s  .  co  m*/

    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) {
    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);/*  w ww.  ja v a2 s  . c o m*/

    Menu fileMenu = new Menu("_File");
    fileMenu.setMnemonicParsing(true);
    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");
    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);//  w w w .  j  ava 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 menu = new Menu("File");
    MenuItem newItem = new MenuItem("New");
    menu.getItems().add(newItem);//from  w  w  w .  ja v  a 2s  .c  om
    menu.getItems().add(new MenuItem("Save"));
    menu.getItems().add(new SeparatorMenuItem());
    menu.getItems().add(new MenuItem("Exit"));

    newItem.setVisible(false);

    menuBar.getMenus().add(menu);

    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");
    CheckMenuItem item = new CheckMenuItem("Item 1");

    tools.getItems().add(item);//from w ww  . jav a2  s  . c  om

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);

    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");
    CheckMenuItem item = new CheckMenuItem();
    item.setText("Item 1");
    tools.getItems().add(item);/*from w  ww  .  ja v  a  2 s .  c  o m*/

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);

    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");

    Image image = new Image(getClass().getResourceAsStream("a.png"));

    CheckMenuItem item = new CheckMenuItem("Item 1", new ImageView(image));
    tools.getItems().add(item);//from w w w  .j  av  a 2  s  .  c  om

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);

    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");

    Image image = new Image(getClass().getResourceAsStream("a.png"));

    CheckMenuItem item = new CheckMenuItem("Item 1", new ImageView(image));
    tools.getItems().add(item);/*from w  w  w .  ja  v  a2s .  c  om*/

    System.out.println(item.isSelected());

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);

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

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