List of usage examples for javafx.scene.control MenuBar prefWidthProperty
public final DoubleProperty prefWidthProperty()
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 a v a 2s .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.setText("Item 1"); tools.getItems().add(item);/*www .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 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 ww.j a va 2 s. c o m*/ 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 .j a va2 s .co m*/ 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"); 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 a2 s . 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(); }
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 2s.com item.setSelected(true); 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 a2 s.co m 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(); }
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("Radio Button Menu Item"); ToggleGroup tGroup = new ToggleGroup(); RadioMenuItem soundAlarmItem = RadioMenuItemBuilder.create().toggleGroup(tGroup).text("On").build(); RadioMenuItem stopAlarmItem = RadioMenuItemBuilder.create().toggleGroup(tGroup).text("Off").selected(true) .build();//w ww .j a va 2 s . c om menu.getItems().add(soundAlarmItem); menu.getItems().add(stopAlarmItem); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); 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("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);//w w w . j a va 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("File"); final MenuItem aboutMenuItem = MenuItemBuilder.create().text("About") .onAction(new EventHandler<ActionEvent>() { @Override//from w w w . j a va 2s . c o m public void handle(ActionEvent e) { System.out.println("You clicked on About!"); } }).accelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.CONTROL_DOWN)).build(); menu.getItems().add(aboutMenuItem); menuBar.getMenus().add(menu); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.getChildren().add(menuBar); primaryStage.setScene(scene); primaryStage.show(); }