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

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);//from  w w w .  j ava 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) {
    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  ww  w  .j  a va 2  s. com*/

    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

private Menu fileMenu() {
    Menu fileMenu = new Menu("File");
    MenuItem newMenuItem = new MenuItem("New");
    MenuItem saveMenuItem = new MenuItem("Save");
    fileMenu.getItems().addAll(newMenuItem, saveMenuItem, new SeparatorMenuItem(), exitMenuItem());
    return fileMenu;
}

From source file:Main.java

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

    MenuBar menuBar = new MenuBar();
    EventHandler<ActionEvent> action = changeTabPlacement();

    Menu menu = new Menu("Direction");
    MenuItem left = new MenuItem("Left");

    left.setOnAction(action);/* w ww.j  a v  a  2s .  com*/
    menu.getItems().add(left);

    MenuItem right = new MenuItem("Right");
    right.setOnAction(action);
    menu.getItems().add(right);

    MenuItem top = new MenuItem("Top");
    top.setOnAction(action);
    menu.getItems().add(top);

    MenuItem bottom = new MenuItem("Bottom");
    bottom.setOnAction(action);
    menu.getItems().add(bottom);

    menuBar.getMenus().add(menu);

    BorderPane borderPane = new BorderPane();

    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    borderPane.setTop(menuBar);

    root.getChildren().add(borderPane);

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

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);//w  ww .  jav a  2s  .  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");

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

    CheckMenuItem item = new CheckMenuItem("Item 1", new ImageView(image));
    tools.getItems().add(item);

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

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);//from   w w w .j  av a  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");

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

    CheckMenuItem item = new CheckMenuItem("Item 1", new ImageView(image));
    tools.getItems().add(item);

    item.setSelected(true);//from  w w  w . j  a  v a  2s.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);

    item.selectedProperty().addListener(new ChangeListener() {

        @Override//from ww w.j  a v  a2 s  .c o m
        public void changed(ObservableValue arg0, Object arg1, Object arg2) {

        }

    });

    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:com.bdb.weather.display.day.DayTemperaturePane.java

@Override
public List<SeriesControl> configure(Menu menu) {
    menu.getItems().add(minMaxLabelsItem);
    minMaxLabelsItem.setOnAction(this);
    List<SeriesControl> controls = new ArrayList<>();
    controls.add(new SeriesControl(HistoricalSeriesInfo.INDOOR_TEMPERATURE_SERIES, true));
    controls.add(new SeriesControl(HistoricalSeriesInfo.LOW_OUTDOOR_TEMPERATURE_SERIES, false));
    controls.add(new SeriesControl(HistoricalSeriesInfo.HIGH_OUTDOOR_TEMPERATURE_SERIES, false));
    controls.add(new SeriesControl(HistoricalSeriesInfo.AVG_OUTDOOR_TEMPERATURE_SERIES, true));
    controls.add(new SeriesControl(HistoricalSeriesInfo.DEW_POINT_SERIES, false));
    controls.add(new SeriesControl(HistoricalSeriesInfo.HEAT_INDEX_SERIES, false));
    controls.add(new SeriesControl(HistoricalSeriesInfo.WIND_CHILL_SERIES, false));

    SensorManager.getInstance().getExtraSensors(SensorType.THERMOMETER).stream().forEach((sensor) -> {
        controls.add(new SeriesControl(sensor.getName(), false));
    });//  ww  w  .ja v  a2 s .c  o m

    XYToolTipGenerator ttg = new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            DateFormat.getTimeInstance(), Temperature.getDefaultFormatter());
    getPlot().getRenderer().setBaseToolTipGenerator(ttg);

    return controls;
}

From source file:com.bekwam.resignator.ResignatorAppMainViewControllerTest.java

@Before
public void init() {

    resignatorAppMainViewController = new ResignatorAppMainViewController();

    Menu mRecentProfiles = new Menu();

    List<MenuItem> rpItems = new ArrayList<>();

    rpItems.add(new MenuItem(noneMenuItemText));

    mRecentProfiles.getItems().clear();
    mRecentProfiles.getItems().addAll(rpItems);

    ActiveConfiguration activeConfiguration = new ActiveConfiguration();

    resignatorAppMainViewController.mRecentProfiles = mRecentProfiles;
    resignatorAppMainViewController.activeConfiguration = activeConfiguration;
}