javafx.scene.control.CheckMenuItem Java Examples

The following examples show how to use javafx.scene.control.CheckMenuItem. 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 vote down vote up
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: JavaFXMenuBarElement.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean marathon_select(String value) {
    MenuBar menuBar = (MenuBar) node;
    ObservableList<Menu> menus = menuBar.getMenus();
    String[] items = value.split("\\>\\>");
    Menu parentMenu = getParentMenu(menus, items[0]);
    List<MenuItem> menuItems = new ArrayList<>();
    for (int i = 1; i < items.length; i++) {
        getChidernMenuItem(parentMenu, items[i], menuItems);
    }
    parentMenu.fire();
    menuItems.stream().forEach((menu) -> {
        if (menu instanceof CheckMenuItem) {
            CheckMenuItem checkMenuItem = (CheckMenuItem) menu;
            checkMenuItem.setSelected(!checkMenuItem.isSelected());
        } else if (menu instanceof RadioMenuItem) {
            RadioMenuItem radioMenuItem = (RadioMenuItem) menu;
            radioMenuItem.setSelected(!isSelected());
        }
        Platform.runLater(() -> menu.fire());
    });
    return true;
}
 
Example #3
Source File: JavaFXContextMenuElement.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean marathon_select(String value) {
    String[] items = value.split("\\>\\>");
    ObservableList<MenuItem> children = contextMenu.getItems();
    List<MenuItem> menuItems = new ArrayList<>();
    for (String item : items) {
        getChidernMenuItem(children, item, menuItems);
    }
    menuItems.stream().forEach((menu) -> {
        if (menu instanceof CheckMenuItem) {
            CheckMenuItem checkMenuItem = (CheckMenuItem) menu;
            checkMenuItem.setSelected(!checkMenuItem.isSelected());
        } else if (menu instanceof RadioMenuItem) {
            RadioMenuItem radioMenuItem = (RadioMenuItem) menu;
            radioMenuItem.setSelected(!isSelected());
        }
        menu.fire();
    });
    contextMenu.hide();
    return true;
}
 
Example #4
Source File: RFXMenuItemTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void specialChars() {
    List<String> path = new ArrayList<>();
    Platform.runLater(() -> {
        Menu menuView = new Menu("View");
        CheckMenuItem titleView = createMenuItem("Tit>le");
        CheckMenuItem binNameView = createMenuItem("Binomial name");
        CheckMenuItem picView = createMenuItem("Picture");
        CheckMenuItem descriptionView = createMenuItem("Decsription");

        menuView.getItems().addAll(titleView, binNameView, picView, descriptionView);
        RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
        path.add(rfxMenuItem.getSelectedMenuPath(titleView));
    });
    new Wait("Waiting for menu selection path") {
        @Override
        public boolean until() {
            return path.size() > 0;
        }
    };
    AssertJUnit.assertEquals("View>>Tit\\>le", path.get(0));
}
 
Example #5
Source File: MainSceneMenu.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #6
Source File: JTreeViewTable.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #7
Source File: JDynamicTable.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #8
Source File: LogFX.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
@MustCallOnJavaFXThread
private Menu viewMenu() {
    Menu menu = new Menu( "_View" );
    menu.setMnemonicParsing( true );

    CheckMenuItem highlight = new CheckMenuItem( "_Highlight Options" );
    highlight.setAccelerator( new KeyCodeCombination( KeyCode.H, KeyCombination.SHORTCUT_DOWN ) );
    highlight.setMnemonicParsing( true );
    bindMenuItemToDialog( highlight, () ->
            showHighlightOptionsDialog( highlightOptions ) );

    MenuItem orientation = new MenuItem( "Switch Pane Orientation" );
    orientation.setAccelerator( new KeyCodeCombination( KeyCode.S,
            KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
    orientation.setOnAction( event -> logsPane.switchOrientation() );

    CheckMenuItem font = new CheckMenuItem( "Fon_t" );
    font.setAccelerator( new KeyCodeCombination( KeyCode.F,
            KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
    font.setMnemonicParsing( true );
    bindMenuItemToDialog( font, () -> showFontPicker( config.fontProperty() ) );

    CheckMenuItem filter = new CheckMenuItem( "Enable _filters" );
    filter.setAccelerator( new KeyCodeCombination( KeyCode.F,
            KeyCombination.SHORTCUT_DOWN ) );
    filter.setMnemonicParsing( true );
    filter.selectedProperty().bindBidirectional( config.filtersEnabledProperty() );

    MenuItem showContextMenu = new MenuItem( "Show Context Menu" );
    showContextMenu.setAccelerator( new KeyCodeCombination( KeyCode.E, KeyCombination.SHORTCUT_DOWN ) );
    showContextMenu.setOnAction( event -> logsPane.showContextMenu() );

    menu.getItems().addAll( highlight, orientation, font, filter, showContextMenu );
    return menu;
}
 
Example #9
Source File: ActionUtils.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static MenuItem createMenuItem(Action action) {
	MenuItem menuItem = (action.selected != null) ? new CheckMenuItem(action.text) : new MenuItem(action.text);
	if (action.accelerator != null)
		menuItem.setAccelerator(action.accelerator);
	if (action.icon != null)
		menuItem.setGraphic(FontAwesomeIconFactory.get().createIcon(action.icon));
	if (action.action != null)
		menuItem.setOnAction(action.action);
	if (action.disable != null)
		menuItem.disableProperty().bind(action.disable);
	if (action.selected != null)
		((CheckMenuItem)menuItem).selectedProperty().bindBidirectional(action.selected);
	return menuItem;
}
 
Example #10
Source File: PluginsStage.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private void itemSelected (ActionEvent e)
// ---------------------------------------------------------------------------------//
{
  CheckMenuItem menuItem = ((CheckMenuItem) e.getSource ());
  PluginEntry pluginEntry = (PluginEntry) menuItem.getUserData ();
  pluginEntry.select (menuItem.isSelected ());
  rebuildMenu ();
}
 
Example #11
Source File: JTreeViewTable.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #12
Source File: JDynamicTable.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #13
Source File: MenuFactory.java    From JetUML with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #14
Source File: EditorFrame.java    From JetUML with GNU General Public License v3.0 5 votes vote down vote up
private void createViewMenu(MenuBar pMenuBar) 
{
	MenuFactory factory = new MenuFactory(RESOURCES);
	pMenuBar.getMenus().add(factory.createMenu("view", false, 
			
			factory.createCheckMenuItem("view.show_grid", false, 
			UserPreferences.instance().getBoolean(BooleanPreference.showGrid), 
				pEvent -> UserPreferences.instance().setBoolean(BooleanPreference.showGrid, 
						((CheckMenuItem) pEvent.getSource()).isSelected())),
		
			factory.createCheckMenuItem("view.show_hints", false, 
			UserPreferences.instance().getBoolean(BooleanPreference.showToolHints),
			pEvent -> UserPreferences.instance().setBoolean(BooleanPreference.showToolHints, 
					((CheckMenuItem) pEvent.getSource()).isSelected())),
			
			factory.createCheckMenuItem("view.verbose_tooltips", false, 
					UserPreferences.instance().getBoolean(BooleanPreference.verboseToolTips),
					pEvent -> UserPreferences.instance().setBoolean(BooleanPreference.verboseToolTips, 
							((CheckMenuItem) pEvent.getSource()).isSelected())),
			
			factory.createCheckMenuItem("view.autoedit_node", false, 
					UserPreferences.instance().getBoolean(BooleanPreference.autoEditNode),
					event -> UserPreferences.instance().setBoolean(BooleanPreference.autoEditNode, 
							((CheckMenuItem) event.getSource()).isSelected())),
	
			factory.createMenuItem("view.diagram_size", false, event -> new DiagramSizeDialog(aMainStage).show())));
}
 
Example #15
Source File: FXUIUtils.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static MenuItem createCheckboxMenuItem(String name, String commandName, String mnemonic) {
    MenuItem menuItem = new CheckMenuItem();
    menuItem.setId(name + "MenuItem");
    Node enabledIcon = getImageFrom(name, "icons/", FromOptions.NULL_IF_NOT_EXISTS);
    if (enabledIcon != null) {
        menuItem.setGraphic(enabledIcon);
    }
    menuItem.setText(commandName);
    if (!"".equals(mnemonic)) {
        menuItem.setAccelerator(KeyCombination.keyCombination(mnemonic));
    }
    return menuItem;
}
 
Example #16
Source File: PluginsStage.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
private void itemSelected (ActionEvent e)
{
  CheckMenuItem menuItem = ((CheckMenuItem) e.getSource ());
  PluginEntry pluginEntry = (PluginEntry) menuItem.getUserData ();
  pluginEntry.select (menuItem.isSelected ());
  rebuildMenu ();
}
 
Example #17
Source File: FxAction.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public void attach(MenuItem m)
{
	m.setOnAction(this);
	m.disableProperty().bind(disabledProperty());

	if(m instanceof CheckMenuItem)
	{
		((CheckMenuItem)m).selectedProperty().bindBidirectional(selectedProperty());
	}
	else if(m instanceof RadioMenuItem)
	{
		((RadioMenuItem)m).selectedProperty().bindBidirectional(selectedProperty());
	}
}
 
Example #18
Source File: JFXMenuCheckableItem.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean isChecked() {
	return ((CheckMenuItem) this.getControl()).isSelected();
}
 
Example #19
Source File: ViewPanel.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
public static CheckMenuItem getDetachPreviewItem() {
    return detachPreviewItem;
}
 
Example #20
Source File: ViewPanel.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
private void initializePreviewContextMenus() {

        CheckMenuItem stopRenderingItem = new CheckMenuItem("Stop rendering");
        CheckMenuItem stopScrollingItem = new CheckMenuItem("Stop scrolling");
        CheckMenuItem stopJumpingItem = new CheckMenuItem("Stop jumping");
        detachPreviewItem = new CheckMenuItem("Detach preview");


        stopRenderingItem.selectedProperty().addListener((observable, oldValue, newValue) -> {
            controller.stopRenderingProperty().setValue(newValue);
        });

        stopScrollingItem.selectedProperty().addListener((observable, oldValue, newValue) -> {
            stopScrolling.setValue(newValue);
        });

        stopJumpingItem.selectedProperty().addListener((observable, oldValue, newValue) -> {
            stopJumping.setValue(newValue);
        });

        detachPreviewItem.selectedProperty().bindBidirectional(editorConfigBean.detachedPreviewProperty());

        MenuItem refresh = MenuItemBuilt.item("Clear image cache").click(e -> {
            webEngine().executeScript("clearImageCache()");
        });

        getWebView().setOnContextMenuRequested(event -> {

            ObservableList<Window> windows = Window.getWindows();

            for (Window window : windows) {
                if (window instanceof ContextMenu) {

                    Optional<Node> nodeOptional = Optional.ofNullable(window)
                            .map(Window::getScene)
                            .map(Scene::getRoot)
                            .map(Parent::getChildrenUnmodifiable)
                            .filter((nodes) -> !nodes.isEmpty())
                            .map(e -> e.get(0))
                            .map(e -> e.lookup(".context-menu"));

                    if (nodeOptional.isPresent()) {
                        ObservableList<Node> childrenUnmodifiable = ((Parent) nodeOptional.get())
                                .getChildrenUnmodifiable();
                        ContextMenuContent cmc = (ContextMenuContent) childrenUnmodifiable.get(0);

                        // add new item:
                        cmc.getItemsContainer().getChildren().add(new Separator());
                        cmc.getItemsContainer().getChildren().add(cmc.new MenuItemContainer(stopRenderingItem));
                        cmc.getItemsContainer().getChildren().add(cmc.new MenuItemContainer(stopScrollingItem));
                        cmc.getItemsContainer().getChildren().add(cmc.new MenuItemContainer(stopJumpingItem));
                        cmc.getItemsContainer().getChildren().add(cmc.new MenuItemContainer(detachPreviewItem));
                    }
                }
            }
        });
    }
 
Example #21
Source File: UIFactory.java    From mcaselector with MIT License 4 votes vote down vote up
public static CheckMenuItem checkMenuItem(Translation translation, boolean selected) {
	CheckMenuItem item = new CheckMenuItem();
	item.textProperty().bind(translation.getProperty());
	item.setSelected(selected);
	return item;
}
 
Example #22
Source File: RFXMenuItemTest.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private static CheckMenuItem createMenuItem(String title) {
    CheckMenuItem cmi = new CheckMenuItem(title);
    cmi.setSelected(true);
    return cmi;
}
 
Example #23
Source File: PhoebusApplication.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
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 #24
Source File: OptionStage.java    From xframium-java with GNU General Public License v3.0 4 votes vote down vote up
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 #25
Source File: OptionStage.java    From dm3270 with Apache License 2.0 4 votes vote down vote up
private void switchMode (ActionEvent e)
{
  CheckMenuItem menuItem = (CheckMenuItem) e.getSource ();
  setMode (menuItem.isSelected () ? Mode.RELEASE : Mode.DEBUG);
}
 
Example #26
Source File: OptionStage.java    From dm3270 with Apache License 2.0 4 votes vote down vote up
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 ();
}
 
Example #27
Source File: OptionStage.java    From xframium-java with GNU General Public License v3.0 4 votes vote down vote up
private void switchMode (ActionEvent e)
{
  CheckMenuItem menuItem = (CheckMenuItem) e.getSource ();
  setMode (menuItem.isSelected () ? Mode.RELEASE : Mode.DEBUG);
}
 
Example #28
Source File: WindowMenuUpdateListener.java    From NSMenuFX with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void addWindowMenuItem(Stage stage, Menu menu) {
	CheckMenuItem item = new CheckMenuItem(stage.getTitle());
	item.setOnAction(event -> stage.toFront());
	createdMenuItems.put(stage, item);
	menu.getItems().add(item);
}
 
Example #29
Source File: DoodleTrace.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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 #30
Source File: JFXMenuCheckableItem.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void setChecked(boolean checked) {
	((CheckMenuItem) this.getControl()).setSelected(checked);
}