List of usage examples for javafx.scene.control MenuBar prefWidthProperty
public final DoubleProperty prefWidthProperty()
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.setOnHiding(new EventHandler<Event>() { @Override//ww w. j av a2 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 ww w . j a v a2 s . co m*/ 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// www . jav a 2 s . co 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//ww w. j av a2 s . c o m 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(); }
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.setOnHiding(new EventHandler<Event>() { @Override//from w w w.ja va 2 s.c om public void handle(Event arg0) { } }); System.out.println(menu.setOnHiding()); 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"); ToggleGroup modalGroup = new ToggleGroup(); RadioMenuItem nonModalItem = RadioMenuItemBuilder.create().toggleGroup(modalGroup).text("On").selected(true) .build();//from www. j av a2 s. c o m nonModalItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Action"); } }); menu.getItems().add(nonModalItem); RadioMenuItem modalItem = RadioMenuItemBuilder.create().toggleGroup(modalGroup).text("Off").selected(true) .build(); modalItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Action"); } }); menu.getItems().add(modalItem); 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(Stage primaryStage) { primaryStage.setTitle("Keyboard"); Group root = new Group(); Scene scene = new Scene(root, 530, 300, Color.WHITE); MenuBar menuBar = new MenuBar(); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.getChildren().add(menuBar);/*from w w w .ja v a 2 s.c o m*/ Menu menu = new Menu("File"); menuBar.getMenus().add(menu); MenuItem newItem = MenuItemBuilder.create().text("New") .accelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN)) .onAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Ctrl-N"); } }).build(); menu.getItems().add(newItem); MenuItem saveItem = MenuItemBuilder.create().text("Save") .accelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN)) .onAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Ctrl-S"); } }).build(); menu.getItems().add(saveItem); menu.getItems().add(new SeparatorMenuItem()); MenuItem exitItem = MenuItemBuilder.create().text("Exit") .accelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN)) .onAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { System.out.println("Ctrl-X"); } }).build(); menu.getItems().add(exitItem); 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);/* ww w .java2 s. co m*/ // File menu - new, save, exit Menu fileMenu = new Menu("File"); MenuItem newMenuItem = new MenuItem("New"); MenuItem saveMenuItem = new MenuItem("Save"); MenuItem exitMenuItem = new MenuItem("Exit"); exitMenuItem.setOnAction(actionEvent -> Platform.exit()); fileMenu.getItems().addAll(newMenuItem, saveMenuItem, new SeparatorMenuItem(), exitMenuItem); Menu webMenu = new Menu("Web"); CheckMenuItem htmlMenuItem = new CheckMenuItem("HTML"); htmlMenuItem.setSelected(true); webMenu.getItems().add(htmlMenuItem); CheckMenuItem cssMenuItem = new CheckMenuItem("CSS"); cssMenuItem.setSelected(true); webMenu.getItems().add(cssMenuItem); Menu sqlMenu = new Menu("SQL"); ToggleGroup tGroup = new ToggleGroup(); RadioMenuItem mysqlItem = new RadioMenuItem("MySQL"); mysqlItem.setToggleGroup(tGroup); RadioMenuItem oracleItem = new RadioMenuItem("Oracle"); oracleItem.setToggleGroup(tGroup); oracleItem.setSelected(true); sqlMenu.getItems().addAll(mysqlItem, oracleItem, new SeparatorMenuItem()); Menu tutorialManeu = new Menu("Tutorial"); tutorialManeu.getItems().addAll(new CheckMenuItem("Java"), new CheckMenuItem("JavaFX"), new CheckMenuItem("Swing")); sqlMenu.getItems().add(tutorialManeu); menuBar.getMenus().addAll(fileMenu, webMenu, sqlMenu); 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 www. j a v 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) { 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);/* w w w . ja va 2s . com*/ 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(); }