Java Code Examples for javafx.scene.control.CheckMenuItem#setSelected()
The following examples show how to use
javafx.scene.control.CheckMenuItem#setSelected() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScenicViewGui.java From scenic-view with GNU General Public License v3.0 | 6 votes |
public CheckMenuItem buildCheckMenuItem(final String text, final String toolTipSelected, final String toolTipNotSelected, final String property, final Boolean value) { final CheckMenuItem menuItem = new CheckMenuItem(text); if (property != null) { Persistence.loadProperty(property, menuItem, value); } else if (value != null) { menuItem.setSelected(value); } menuItem.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(final ObservableValue<? extends Boolean> arg0, final Boolean arg1, final Boolean newValue) { setStatusText(newValue ? toolTipSelected : toolTipNotSelected, 4000); } }); return menuItem; }
Example 2
Source File: MainSceneMenu.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Create menu items * * @param title * @param toolName * @return CheckMenuItem */ private CheckMenuItem createMenuItem(String title, String toolName) { CheckMenuItem cmi = new CheckMenuItem(title); cmi.setSelected(false); cmi.selectedProperty().addListener(new ChangeListener<Boolean>() { public void changed(ObservableValue ov, Boolean old_val, Boolean new_val) { if (new_val) { long SLEEP_TIME = 100; cmi.setSelected(true); Platform.runLater(() -> { // mainScene.openSwingTab(); }); try { TimeUnit.MILLISECONDS.sleep(SLEEP_TIME); } catch (InterruptedException e) { e.printStackTrace(); } SwingUtilities.invokeLater(() -> { desktop.openToolWindow(toolName); // desktop.repaint(); }); // desktop.repaint(); } else { cmi.setSelected(false); SwingUtilities.invokeLater(() -> { desktop.closeToolWindow(toolName); // desktop.repaint(); }); } } }); return cmi; }
Example 3
Source File: MenuFactory.java From JetUML with GNU General Public License v3.0 | 5 votes |
/** * Create a checkbox menu. * @param pPrefix A string such as "file.open" that indicates the menu->submenu path * @param pHandler The callback to execute when the menu item is selected. * @return A menu item for the action described. */ public MenuItem createCheckMenuItem(String pPrefix, boolean pDiagramSpecific, boolean pInitialState, EventHandler<ActionEvent> pHandler) { CheckMenuItem item = new CheckMenuItem(); item.setUserData(pDiagramSpecific); initialize(item, pPrefix); item.setOnAction(pHandler); item.setSelected(pInitialState); return item; }
Example 4
Source File: JDynamicTable.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private MenuItem createMenuItem(TableColumn column) { CheckMenuItem item = new CheckMenuItem(); boolean visible = dynamicColumnModel.isVisible(column); item.setSelected(visible); item.setOnAction(new MenuAction(column, visible)); return item; }
Example 5
Source File: JTreeViewTable.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private CheckMenuItem createMenuItem(TableColumn column) { CheckMenuItem item = new CheckMenuItem(); boolean visible = dynamicColumnModel.isVisible(column); item.setSelected(visible); Action menuAction = new MenuAction(column, visible); item.setText(menuAction.getText()); item.setOnAction(menuAction); return item; }
Example 6
Source File: JDynamicTable.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private MenuItem createMenuItem(TableColumn column) { CheckMenuItem item = new CheckMenuItem(); boolean visible = dynamicColumnModel.isVisible(column); item.setSelected(visible); item.setOnAction(new MenuAction(column, visible)); return item; }
Example 7
Source File: JTreeViewTable.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private CheckMenuItem createMenuItem(TableColumn column) { CheckMenuItem item = new CheckMenuItem(); boolean visible = dynamicColumnModel.isVisible(column); item.setSelected(visible); Action menuAction = new MenuAction(column, visible); item.setText(menuAction.getText()); item.setOnAction(menuAction); return item; }
Example 8
Source File: SpectraIdentificationResultsWindowFX.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public SpectraIdentificationResultsWindowFX() { super(); pnMain = new BorderPane(); this.setScene(new Scene(pnMain)); getScene().getStylesheets() .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets()); pnMain.setPrefSize(1000, 600); pnMain.setMinSize(700, 500); setMinWidth(700); setMinHeight(500); setTitle("Processing..."); pnGrid = new GridPane(); // any number of rows noMatchesFound = new Label("I'm working on it"); noMatchesFound.setFont(headerFont); // yellow noMatchesFound.setTextFill(Color.web("0xFFCC00")); pnGrid.add(noMatchesFound, 0, 0); pnGrid.setVgap(5); // Add the Windows menu MenuBar menuBar = new MenuBar(); // menuBar.add(new WindowsMenu()); Menu menu = new Menu("Menu"); // set font size of chart MenuItem btnSetup = new MenuItem("Setup dialog"); btnSetup.setOnAction(e -> { Platform.runLater(() -> { if (MZmineCore.getConfiguration() .getModuleParameters(SpectraIdentificationResultsModule.class) .showSetupDialog(true) == ExitCode.OK) { showExportButtonsChanged(); } }); }); menu.getItems().add(btnSetup); CheckMenuItem cbCoupleZoomY = new CheckMenuItem("Couple y-zoom"); cbCoupleZoomY.setSelected(true); cbCoupleZoomY.setOnAction(e -> setCoupleZoomY(cbCoupleZoomY.isSelected())); menu.getItems().add(cbCoupleZoomY); menuBar.getMenus().add(menu); pnMain.setTop(menuBar); scrollPane = new ScrollPane(pnGrid); pnMain.setCenter(scrollPane); scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); totalMatches = new ArrayList<>(); matchPanels = new HashMap<>(); setCoupleZoomY(true); show(); }
Example 9
Source File: UIFactory.java From mcaselector with MIT License | 4 votes |
public static CheckMenuItem checkMenuItem(Translation translation, boolean selected) { CheckMenuItem item = new CheckMenuItem(); item.textProperty().bind(translation.getProperty()); item.setSelected(selected); return item; }
Example 10
Source File: RFXMenuItemTest.java From marathonv5 with Apache License 2.0 | 4 votes |
private static CheckMenuItem createMenuItem(String title) { CheckMenuItem cmi = new CheckMenuItem(title); cmi.setSelected(true); return cmi; }
Example 11
Source File: PhoebusApplication.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private MenuBar createMenu(final Stage stage) { final MenuBar menuBar = new MenuBar(); // For Mac OS X, use it's menu bar on top of screen if (PlatformInfo.is_mac_os_x) menuBar.setUseSystemMenuBar(true); // File final MenuItem open = new MenuItem(Messages.Open, ImageCache.getImageView(getClass(), "/icons/fldr_obj.png")); open.setOnAction(event -> fileOpen(stage, false)); final MenuItem open_with = new MenuItem(Messages.OpenWith, ImageCache.getImageView(getClass(), "/icons/fldr_obj.png")); open_with.setOnAction(event -> fileOpen(stage, true)); top_resources_menu = new Menu(Messages.TopResources, ImageCache.getImageView(getClass(), "/icons/fldr_obj.png")); top_resources_menu.setDisable(true); final MenuItem file_save = new MenuItem(Messages.Save, ImageCache.getImageView(getClass(), "/icons/save_edit.png")); file_save.setOnAction(event -> JobManager.schedule(Messages.Save, monitor -> active_item_with_input.get().save(monitor))); final MenuItem file_save_as = new MenuItem(Messages.SaveAs, ImageCache.getImageView(getClass(), "/icons/saveas_edit.png")); file_save_as.setOnAction(event ->JobManager.schedule(Messages.SaveAs, monitor -> active_item_with_input.get().save_as(monitor))); final MenuItem exit = new MenuItem(Messages.Exit); exit.setOnAction(event -> { if (closeMainStage(null)) stop(); }); final Menu file = new Menu(Messages.File, null, open, open_with, top_resources_menu, new SeparatorMenuItem(), file_save, file_save_as, new SeparatorMenuItem(), exit); file.setOnShowing(event -> { final DockItemWithInput input_item = active_item_with_input.get(); if (input_item == null) { file_save.setDisable(true); file_save_as.setDisable(true); } else { file_save.setDisable(! input_item.isDirty()); file_save_as.setDisable(! input_item.isSaveAsSupported()); } }); menuBar.getMenus().add(file); // Application Contributions final Menu applicationsMenu = new Menu(Messages.Applications); final MenuTreeNode node = MenuEntryService.getInstance().getMenuEntriesTree(); addMenuNode(applicationsMenu, node); menuBar.getMenus().add(applicationsMenu); // Window show_tabs = new CheckMenuItem(Messages.AlwaysShowTabs); show_tabs.setSelected(DockPane.isAlwaysShowingTabs()); show_tabs.setOnAction(event -> DockPane.alwaysShowTabs(show_tabs.isSelected())); show_toolbar = new CheckMenuItem(Messages.ShowToolbar); show_toolbar.setOnAction(event -> showToolbar(show_toolbar.isSelected())); save_layout = new SaveLayoutMenuItem(this, memento_files); delete_layouts = new DeleteLayoutsMenuItem(this, memento_files); final Menu menu = new Menu(Messages.Window, null, show_tabs, show_toolbar, new SeparatorMenuItem(), save_layout, load_layout, delete_layouts, new SeparatorMenuItem(), /* Full Screen placeholder */ new FullScreenAction(stage)); // Update Full screen action when shown to get correct enter/exit FS mode menu.setOnShowing(event -> { // Last menu item final int full_screen_index = menu.getItems().size()-1; final FullScreenAction full_screen = new FullScreenAction(stage); if (! AuthorizationService.hasAuthorization("full_screen")) full_screen.setDisable(true); menu.getItems().set(full_screen_index, full_screen); }); menuBar.getMenus().add(menu); // Help final MenuItem content = createMenuItem(new OpenHelp()); final MenuItem about = createMenuItem(new OpenAbout()); menuBar.getMenus().add(new Menu(Messages.Help, null, about, content)); return menuBar; }
Example 12
Source File: OptionStage.java From xframium-java with GNU General Public License v3.0 | 4 votes |
public OptionStage (Preferences prefs, PluginsStage pluginsStage) { this.prefs = prefs; String optionSelected = prefs.get ("Function", "Terminal"); String runMode = prefs.get ("Mode", "Release"); release = false; //release = runMode.equals ("Release"); serverSitesListStage = new SiteListStage (prefs, "Server", 10, true); clientSitesListStage = new SiteListStage (prefs, "Client", 6, false); Node row1 = options (optionList, functionsGroup, 0, 2); Node row2 = options (optionList, functionsGroup, 2, 2); buildComboBoxes (); HBox functionsBox1 = row ("Function", row1); HBox functionsBox2 = row ("", row2); functionsBox.getChildren ().addAll (functionsBox1, functionsBox2); functionsBox.setPadding (new Insets (10, 10, 0, 10)); serverBox = row ("Server", serverComboBox, editServersButton); serverBox.setPadding (new Insets (10, 10, 10, 10));// trbl HBox clientBox = row ("Client", clientComboBox, editClientsButton); HBox spyBox = row ("Replay", fileComboBox, editLocationButton); clientSpyBox.getChildren ().addAll (clientBox, spyBox); clientSpyBox.setPadding (new Insets (0, 10, 10, 10)); buttonsBox = buttons (); innerPane.setTop (functionsBox); innerPane.setCenter (serverBox); outerPane.setCenter (innerPane); outerPane.setBottom (buttonsBox); setMode (release ? Mode.RELEASE : Mode.DEBUG); functionsGroup.selectedToggleProperty ().addListener ( (ov, oldToggle, newToggle) -> { if (newToggle != null) disableButtons ((String) newToggle.getUserData ()); }); if (release) optionSelected = "Terminal"; boolean found = false; for (int i = 0; i < optionList.length; i++) if (optionList[i].equals (optionSelected)) { functionsGroup.selectToggle (functionsGroup.getToggles ().get (i)); found = true; break; } if (!found) functionsGroup.selectToggle (functionsGroup.getToggles ().get (2)); // Terminal disableButtons (optionSelected); editLocationButton.setOnAction (e -> editLocation ()); Menu menuCommands = new Menu ("Commands"); menuBar.getMenus ().add (menuCommands); outerPane.setTop (menuBar); toggleModeMenuItem = new CheckMenuItem ("Release mode"); menuCommands.getItems ().addAll (toggleModeMenuItem, pluginsStage.getEditMenuItem ()); toggleModeMenuItem.setSelected (runMode.equals ("Release")); toggleModeMenuItem.setOnAction (e -> switchMode (e)); toggleModeMenuItem.setAccelerator (new KeyCodeCombination (KeyCode.M, KeyCombination.SHORTCUT_DOWN)); menuBar.setUseSystemMenuBar (SYSTEM_MENUBAR); if (!SYSTEM_MENUBAR) { MenuItem quitMenuItem = new MenuItem ("Quit"); menuCommands.getItems ().addAll (new SeparatorMenuItem (), quitMenuItem); quitMenuItem.setOnAction (e -> Platform.exit ()); quitMenuItem.setAccelerator (new KeyCodeCombination (KeyCode.Q, KeyCombination.SHORTCUT_DOWN)); } setResizable (false); setOnCloseRequest (e -> Platform.exit ()); setScene (new Scene (outerPane)); okButton.requestFocus (); }
Example 13
Source File: DoodleTrace.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void updateAppBar(AppBar appBar) { appBar.setTitleText("Doodle Trace"); //=================== // Floating buttons //=================== // Play animation button (Bottom Center) FloatingActionButton animateButton = new FloatingActionButton( MaterialDesignIcon.PLAY_ARROW.text, animAction); animateButton.setFloatingActionButtonHandler( FloatingActionButton.BOTTOM_CENTER); animateButton.showOn(this); // Clear Button (Botton Right) FloatingActionButton clearButton = new FloatingActionButton( MaterialDesignIcon.REFRESH.text, clearAction); clearButton.setFloatingActionButtonHandler( FloatingActionButton.BOTTOM_RIGHT); clearButton.showOn(this); //=================== // Menu Items //=================== // Checkbox Menu item to show or hide floating button controls CheckMenuItem showControlsMenuItem = new CheckMenuItem("Show/Hide Controls"); showControlsMenuItem.setSelected(true); showControlsMenuItem.selectedProperty().addListener((obv, ov, nv) -> { if (nv) { animateButton.show(); clearButton.show(); } else { animateButton.hide(); clearButton.hide(); } }); // Menu item to animate MenuItem animateMenuItem = new MenuItem("Animate", MaterialDesignIcon.PLAY_ARROW.graphic()); animateMenuItem.setOnAction(animAction); // Menu item to clear MenuItem clearMenuItem = new MenuItem("Clear", MaterialDesignIcon.REFRESH.graphic()); clearMenuItem.setOnAction(clearAction); appBar.getMenuItems() .addAll(showControlsMenuItem, animateMenuItem, clearMenuItem); }
Example 14
Source File: OptionStage.java From dm3270 with Apache License 2.0 | 4 votes |
public OptionStage (Preferences prefs, PluginsStage pluginsStage) { this.prefs = prefs; String optionSelected = prefs.get ("Function", "Terminal"); String runMode = prefs.get ("Mode", "Release"); release = runMode.equals ("Release"); serverSitesListStage = new SiteListStage (prefs, "Server", 10, true); clientSitesListStage = new SiteListStage (prefs, "Client", 6, false); Node row1 = options (optionList, functionsGroup, 0, 2); Node row2 = options (optionList, functionsGroup, 2, 2); buildComboBoxes (); HBox functionsBox1 = row ("Function", row1); HBox functionsBox2 = row ("", row2); functionsBox.getChildren ().addAll (functionsBox1, functionsBox2); functionsBox.setPadding (new Insets (10, 10, 0, 10)); serverBox = row ("Server", serverComboBox, editServersButton); serverBox.setPadding (new Insets (10, 10, 10, 10));// trbl HBox clientBox = row ("Client", clientComboBox, editClientsButton); HBox spyBox = row ("Replay", fileComboBox, editLocationButton); clientSpyBox.getChildren ().addAll (clientBox, spyBox); clientSpyBox.setPadding (new Insets (0, 10, 10, 10)); buttonsBox = buttons (); innerPane.setTop (functionsBox); innerPane.setCenter (serverBox); outerPane.setCenter (innerPane); outerPane.setBottom (buttonsBox); setMode (release ? Mode.RELEASE : Mode.DEBUG); functionsGroup.selectedToggleProperty ().addListener ( (ov, oldToggle, newToggle) -> { if (newToggle != null) disableButtons ((String) newToggle.getUserData ()); }); if (release) optionSelected = "Terminal"; boolean found = false; for (int i = 0; i < optionList.length; i++) if (optionList[i].equals (optionSelected)) { functionsGroup.selectToggle (functionsGroup.getToggles ().get (i)); found = true; break; } if (!found) functionsGroup.selectToggle (functionsGroup.getToggles ().get (2)); // Terminal disableButtons (optionSelected); editLocationButton.setOnAction (e -> editLocation ()); Menu menuCommands = new Menu ("Commands"); menuBar.getMenus ().add (menuCommands); outerPane.setTop (menuBar); toggleModeMenuItem = new CheckMenuItem ("Release mode"); menuCommands.getItems ().addAll (toggleModeMenuItem, pluginsStage.getEditMenuItem ()); toggleModeMenuItem.setSelected (runMode.equals ("Release")); toggleModeMenuItem.setOnAction (e -> switchMode (e)); toggleModeMenuItem.setAccelerator (new KeyCodeCombination (KeyCode.M, KeyCombination.SHORTCUT_DOWN)); menuBar.setUseSystemMenuBar (SYSTEM_MENUBAR); if (!SYSTEM_MENUBAR) { MenuItem quitMenuItem = new MenuItem ("Quit"); menuCommands.getItems ().addAll (new SeparatorMenuItem (), quitMenuItem); quitMenuItem.setOnAction (e -> Platform.exit ()); quitMenuItem.setAccelerator (new KeyCodeCombination (KeyCode.Q, KeyCombination.SHORTCUT_DOWN)); } setResizable (false); setOnCloseRequest (e -> Platform.exit ()); setScene (new Scene (outerPane)); okButton.requestFocus (); }