Example usage for javafx.scene.control Menu setOnHidden

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

Introduction

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

Prototype

public final void setOnHidden(EventHandler<Event> value) 

Source Link

Usage

From source file:Main.java

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

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    Menu menu = new Menu("File");
    menu.setOnHidden(new EventHandler<Event>() {
        @Override//from w w  w .ja  v a2s  . c  om
        public void handle(Event arg0) {
        }
    });
    MenuItem newItem = new MenuItem("New", null);
    newItem.setOnMenuValidation(new EventHandler<Event>() {
        @Override
        public void handle(Event arg0) {
        }
    });

    menu.getItems().add(newItem);
    menu.getItems().add(new SeparatorMenuItem());

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

From source file:Main.java

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

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    Menu menu = new Menu("File");
    menu.setOnHidden(new EventHandler<Event>() {
        @Override/*  w ww  .  j av a  2  s . c  o  m*/
        public void handle(Event arg0) {
        }
    });
    MenuItem newItem = new MenuItem("New", null);
    newItem.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            System.out.println("Action");
        }
    });

    menu.getItems().add(newItem);
    menu.getItems().add(new SeparatorMenuItem());

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

From source file:Main.java

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

    MenuBar menuBar = new MenuBar();
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

    Menu menu = new Menu("File");
    menu.setOnHidden(new EventHandler<Event>() {
        @Override//from   w  w  w  .j a va 2s . com
        public void handle(Event arg0) {
        }
    });
    System.out.println(menu.getOnHidden());

    MenuItem newItem = new MenuItem("New", null);
    newItem.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            System.out.println("Action");
        }
    });

    menu.getItems().add(newItem);
    menu.getItems().add(new SeparatorMenuItem());

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