List of usage examples for javafx.scene.control CheckMenuItem CheckMenuItem
public CheckMenuItem(String text)
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);/*from ww w . j ava 2s.co m*/ 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 . com*/ root.getChildren().add(menuBar); 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
@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.j ava2 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
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 . j a v a2 s. 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 w w . 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.bdb.weather.display.day.DayXYPlotPane.java
private void createChartElements() { ///*from ww w .j a v a2 s . c o m*/ // Set up the Domain Axis (X) // plot = new XYPlot(); dateAxis = new DateAxis("Time"); dateAxis.setAutoRange(false); dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 1, new SimpleDateFormat("h a"))); dateAxis.setVerticalTickLabels(true); plot.setDomainAxis(dateAxis); plot.setRangeAxis(leftAxis); plot.setDataset(0, datasetLeft); if (rightAxis != null) { plot.setRangeAxis(1, rightAxis); plot.mapDatasetToRangeAxis(1, 1); plot.setDataset(1, datasetRight); } plot.setNoDataMessage("There is no data for the specified day"); // // Set up the renderer to generate tool tips, not show shapes // XYLineAndShapeRenderer renderer = new XYLine3DRenderer(); renderer.setBaseShapesVisible(false); renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); //renderer.setDefaultEntityRadius(1); plot.setRenderer(0, renderer); renderer = new XYLine3DRenderer(); renderer.setBaseShapesVisible(false); renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); //renderer.setDefaultEntityRadius(1); plot.setRenderer(1, renderer); // // Setup the cross hairs that are displayed when the user clicks on the plot // plot.setRangeCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(true); plot.setDomainCrosshairVisible(true); // // Create the chart that contains the plot and the panel that contains the chart // chart = new JFreeChart(plot); ChartFactory.getChartTheme().apply(chart); chartViewer = new ChartViewer(chart); chartViewer.setMaxHeight(500); chartViewer.setMaxWidth(800); // // Add the Day/Night indicator option to the chart panels context menu // ContextMenu menu = chartViewer.getContextMenu(); displayMenu = new Menu("Display"); dayNightItem = new CheckMenuItem("Day/Night Indicators"); dayNightItem.setSelected(true); displayMenu.getItems().add(dayNightItem); dayNightItem.setOnAction(this); menu.getItems().add(displayMenu); }
From source file:com.bdb.weather.display.day.DayXYPlotPane.java
private void doConfigure(Menu menu) { List<SeriesControl> controls = configure(displayMenu); int tableColumn = 1; for (SeriesControl control : controls) { HistoricalSeriesInfo info = HistoricalSeriesInfo.find(control.name); if (info != null) { TimeSeries timeSeries = new TimeSeries(info.getSeriesName()); CheckMenuItem menuItem = new CheckMenuItem(info.getSeriesName()); menuItem.setSelected(control.displayInitially); SeriesEntry entry = new SeriesEntry(info, timeSeries, tableColumn, menuItem, control.leftAxis); entries.add(entry);//w ww. j a v a 2 s . co m TableColumn<HistoricalRecord, String> col = new TableColumn<>(entry.seriesInfo.getSeriesName()); col.setCellValueFactory(entry); dataTable.getColumns().add(col); menu.getItems().add(menuItem); menuItem.setOnAction(this); tableColumn++; } } }
From source file:dtv.controller.FXMLMainController.java
public void init(ObservableList<DVBChannel> serviceData, TableView<DVBChannel> table, TableColumn<DVBChannel, Integer> idx, TableColumn<DVBChannel, String> name, TableColumn<DVBChannel, String> type, TableColumn<DVBChannel, String> ppr) { table.setEditable(true);//from w ww .j a va 2 s . c o m idx.setCellValueFactory(cellData -> cellData.getValue().idxProperty().asObject()); name.setCellValueFactory(cellData -> cellData.getValue().nameProperty()); name.setEditable(true); type.setCellValueFactory(cellData -> cellData.getValue().typeProperty()); // nid.setCellValueFactory(cellData -> cellData.getValue().nidProperty().asObject()); ppr.setCellValueFactory(cellData -> cellData.getValue().pprProperty()); // newCol.setCellValueFactory(cellData -> cellData.getValue().neewProperty()); // Context menu table.setRowFactory(tableView -> { final TableRow<DVBChannel> row = new TableRow<>(); final ContextMenu rowMenu = new ContextMenu(); final MenuItem removeItem = new MenuItem("Delete"); removeItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { final DVBChannel service = row.getItem(); serviceData.removeAll(service); } }); rowMenu.getItems().addAll(removeItem); row.contextMenuProperty().bind(Bindings.when(Bindings.isNotNull(row.itemProperty())).then(rowMenu) .otherwise((ContextMenu) null)); return row; }); ppr.setCellFactory(col -> { final TableCell<DVBChannel, String> cell = new TableCell<>(); cell.textProperty().bind(cell.itemProperty()); cell.itemProperty().addListener((obs, oldValue, newValue) -> { if (newValue != null) { final ContextMenu cellMenu = new ContextMenu(); for (String pref : Utils.prefTab) { final CheckMenuItem prefMenuItem = new CheckMenuItem(pref); if (Utils.isPreferenceOn(cell.getText(), pref)) { prefMenuItem.setSelected(true); } prefMenuItem.selectedProperty().addListener((obs1, old_val, new_val) -> { final String new_ppr; final DVBChannel service = (DVBChannel) cell.getTableRow().getItem(); if (new_val) { new_ppr = Utils.add_ppr(cell.getText(), pref); } else { new_ppr = Utils.remove_ppr(cell.getText(), pref); } service.setPpr(new_ppr); service.setModified(true); }); cellMenu.getItems().add(prefMenuItem); cell.setContextMenu(cellMenu); } } else { cell.setContextMenu(null); } }); return cell; }); // Editable service name name.setCellFactory(p -> new EditingCell()); name.setOnEditCommit(t -> { final DVBChannel service = t.getTableView().getItems().get(t.getTablePosition().getRow()); service.setName(t.getNewValue()); service.setModified(true); }); }
From source file:Main.java
private static CheckMenuItem createMenuItem(String title, final Node node) { CheckMenuItem cmi = new CheckMenuItem(title); cmi.setSelected(true);/*from w w w . j a v a 2s . co m*/ cmi.selectedProperty().addListener(new ChangeListener<Boolean>() { public void changed(ObservableValue ov, Boolean old_val, Boolean new_val) { node.setVisible(new_val); } }); return cmi; }