List of usage examples for javafx.scene.control RadioMenuItem setSelected
@Override public final void setSelected(boolean value)
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);//w w w . j av a 2 s. c o 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
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); alarmMenu.getItems().addAll(soundAlarmItem, stopAlarmItem, new SeparatorMenuItem()); return alarmMenu; }