List of usage examples for javafx.scene.control Menu Menu
public Menu(String text)
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) { 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 w w . ja v a 2s . com // 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(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"); MenuItem exitItem = new MenuItem("Exit", null); exitItem.setMnemonicParsing(true);/*from w w w .j a v a 2 s . c o m*/ exitItem.setAccelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN)); exitItem.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { Platform.exit(); } }); menu.getItems().add(exitItem); 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();/* w w w . j a v a 2s . 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);// ww w. j a v a2 s.c om 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
private Menu cameraMenu() { Menu cameraMenu = new Menu("Cameras"); CheckMenuItem cam1MenuItem = new CheckMenuItem("Show Camera 1"); cam1MenuItem.setSelected(true); CheckMenuItem cam2MenuItem = new CheckMenuItem("Show Camera 2"); cam2MenuItem.setSelected(true); cameraMenu.getItems().addAll(cam1MenuItem, cam2MenuItem); return cameraMenu; }
From source file:Main.java
private Menu alarmMenu() { Menu alarmMenu = new Menu("Alarm"); RadioMenuItem soundAlarmItem = new RadioMenuItem("Sound Alarm"); RadioMenuItem stopAlarmItem = new RadioMenuItem("Alarm Off"); Menu contingencyPlans = new Menu("Plans"); contingencyPlans.getItems().addAll(new CheckMenuItem("A"), new CheckMenuItem("B"), new CheckMenuItem("C")); alarmMenu.getItems().add(contingencyPlans); ToggleGroup tGroup = new ToggleGroup(); soundAlarmItem.setToggleGroup(tGroup); stopAlarmItem.setToggleGroup(tGroup); stopAlarmItem.setSelected(true);//from w w w . jav a 2s .c o m alarmMenu.getItems().addAll(soundAlarmItem, stopAlarmItem, new SeparatorMenuItem()); return alarmMenu; }
From source file:jviewmda.JViewMda.java
@Override public void start(Stage primaryStage) { m_stage = primaryStage;//w ww .j a v a 2 s .com String array_path = ""; Parameters params = getParameters(); List<String> unnamed_params = params.getUnnamed(); if (unnamed_params.size() > 0) { array_path = unnamed_params.get(0); } // FOR DEBUGING PURPOSES if (array_path.length() == 0) { //String debug_path = "/home/magland/wisdm/www/wisdmfileserver/files/fetalmri/sessions/SESSION1/crops/FNP001A-coronal.crop.mda"; String debug_path = "/home/magland/data/LesionProbe/Images/ID001_FLAIR.nii"; if ((new File(debug_path)).exists()) { array_path = debug_path; } } Menu menu; MenuItem item; MenuBar menubar = new MenuBar(); //file menu menu = new Menu("File"); menubar.getMenus().add(menu); item = new MenuItem("Open..."); item.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN)); item.setOnAction(e -> on_file_open()); menu.getItems().add(item); item = new MenuItem("Save As..."); item.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN)); item.setOnAction(e -> on_file_saveas()); menu.getItems().add(item); menu.getItems().add(new SeparatorMenuItem()); ///////////////////////////////////////////// item = new MenuItem("Exit"); item.setAccelerator(new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN)); item.setOnAction(e -> on_file_exit()); menu.getItems().add(item); //view menu menu = new Menu("View"); menubar.getMenus().add(menu); item = new MenuItem("Zoom In"); item.setAccelerator(new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN)); item.setOnAction(e -> on_zoom_in()); menu.getItems().add(item); item = new MenuItem("Zoom Out"); item.setAccelerator( new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN)); item.setOnAction(e -> on_zoom_out()); menu.getItems().add(item); menu.getItems().add(new SeparatorMenuItem()); ///////////////////////////////////////////// { CheckMenuItem item0 = new CheckMenuItem("Top Controls"); item0.setSelected(true); item0.setOnAction(e -> { m_widget.setTopControlsVisible(item0.isSelected()); }); menu.getItems().add(item0); } { CheckMenuItem item0 = new CheckMenuItem("Bottom Controls"); item0.setSelected(true); item0.setOnAction(e -> { m_widget.setBottomControlsVisible(item0.isSelected()); }); menu.getItems().add(item0); } { CheckMenuItem item0 = new CheckMenuItem("Brightness/Contrast"); item0.setSelected(true); item0.setOnAction(e -> { m_widget.setBrightnessContrastVisible(item0.isSelected()); }); menu.getItems().add(item0); } { CheckMenuItem item0 = new CheckMenuItem("Slice Slider"); item0.setSelected(true); item0.setOnAction(e -> { m_widget.setSliceSliderVisible(item0.isSelected()); }); menu.getItems().add(item0); } //selection menu menu = new Menu("Selection"); menubar.getMenus().add(menu); Map<String, CheckMenuItem> mode_items = new HashMap<>(); m_selection_mode_items = mode_items; mode_items.put("rectangle", new CheckMenuItem("Rectangle")); mode_items.put("ellipse", new CheckMenuItem("Ellipse")); Set<String> keys = mode_items.keySet(); for (String key : keys) { CheckMenuItem item0 = mode_items.get(key); menu.getItems().add(item0); item0.setOnAction(evt -> { on_selection_mode_changed(key); }); } mode_items.get("rectangle").setSelected(true); VBox root = new VBox(); root.getChildren().addAll(menubar, m_widget); Scene scene = new Scene(root, 500, 450); primaryStage.setTitle("JViewMda"); primaryStage.setScene(scene); primaryStage.show(); if (array_path.length() > 0) { open_file(array_path); } m_prefs = Preferences.userNodeForPackage(this.getClass()); }
From source file:com.cdd.bao.editor.EditSchema.java
public EditSchema(Stage stage) { this.stage = stage; if (MainApplication.icon != null) stage.getIcons().add(MainApplication.icon); menuBar = new MenuBar(); menuBar.setUseSystemMenuBar(true);//from ww w. j a v a 2 s . c o m menuBar.getMenus().add(menuFile = new Menu("_File")); menuBar.getMenus().add(menuEdit = new Menu("_Edit")); menuBar.getMenus().add(menuValue = new Menu("_Value")); menuBar.getMenus().add(menuView = new Menu("Vie_w")); createMenuItems(); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true); treeView.setCellFactory(p -> new HierarchyTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> { if (oldVal != null) pullDetail(oldVal); if (newVal != null) pushDetail(newVal); }); treeView.focusedProperty() .addListener((val, oldValue, newValue) -> Platform.runLater(() -> maybeUpdateTree())); detail = new DetailPane(this); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(detail); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); progBar = new ProgressBar(); progBar.setMaxWidth(Double.MAX_VALUE); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); root.setBottom(progBar); BorderPane.setMargin(progBar, new Insets(2, 2, 2, 2)); Scene scene = new Scene(root, 1000, 800, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); treeRoot.getChildren().add(treeTemplate = new TreeItem<>(new Branch(this, "Template"))); treeRoot.getChildren().add(treeAssays = new TreeItem<>(new Branch(this, "Assays"))); treeTemplate.setExpanded(true); treeAssays.setExpanded(true); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item stage.setOnCloseRequest(event -> { if (!confirmClose()) event.consume(); }); updateTitle(); // loading begins in a background thread, and is updated with a status bar Vocabulary.Listener listener = new Vocabulary.Listener() { public void vocabLoadingProgress(Vocabulary vocab, float progress) { Platform.runLater(() -> { progBar.setProgress(progress); if (vocab.isLoaded()) root.getChildren().remove(progBar); }); } public void vocabLoadingException(Exception ex) { ex.printStackTrace(); } }; Vocabulary.globalInstance(listener); }
From source file:de.pixida.logtest.designer.MainWindow.java
private List<Menu> createMenus() { final Menu file = new Menu("File"); this.createAndAppendFileMenuItems(file); final Menu help = new Menu("Help"); this.createAndAppendHelpMenuItems(help); return Arrays.asList(file, help); }