Java Code Examples for javafx.scene.control.ToggleButton#isSelected()
The following examples show how to use
javafx.scene.control.ToggleButton#isSelected() .
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: ToggleEditor.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public ValueType getValue() { ObservableList<ToggleButton> buttons = segmentedButton.getButtons(); for (ToggleButton button : buttons) { if (button.isSelected()) { String buttonText = button.getText(); for (ValueType toggleValue : toggleValues) { if (toggleValue.toString().equals(buttonText)) { return toggleValue; } } } } return null; }
Example 2
Source File: ToggleParameterSetEditor.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
@Override public ValueType getValue() { ObservableList<ToggleButton> buttons = segmentedButton.getButtons(); for (ToggleButton button : buttons) { if (button.isSelected()) { String buttonText = button.getText(); for (HashMap.Entry<String, ParameterSet> entry : toggleValues.entrySet()) { segmentedButton.getButtons().add(new ToggleButton(entry.getKey())); if (entry.getKey().equals(buttonText)) { return (ValueType) entry.getKey(); } } } } return null; }
Example 3
Source File: DisplayImageController.java From Augendiagnose with GNU General Public License v2.0 | 6 votes |
/** * Perform the display of overlay after toggleButton is pressed. * * @param button * The button. */ private void handleBtnOverlayPressed(final ToggleButton button) { if (button.isSelected()) { String btnId = button.getId(); int buttonPosition; switch (btnId) { case "mBtnOverlayCircle": buttonPosition = 0; break; default: String indexStr = btnId.substring("mBtnOverlay".length()); buttonPosition = Integer.parseInt(indexStr); } int overlayType = PreferenceUtil.getIndexedPreferenceInt(KEY_INDEXED_OVERLAY_TYPE, buttonPosition, -1); updateResolution(NORMAL); showOverlay(overlayType); } else { showOverlay(null); } }
Example 4
Source File: DisplayPositionSelector.java From Quelea with GNU General Public License v3.0 | 5 votes |
public int getSelectedButtonIndex() { for (ToggleButton button : buttons) { if (button.isSelected()) { return buttons.indexOf(button); } } return -1; }
Example 5
Source File: NavigationTabs.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Indicate the active tab, notify listeners * @param pressed Button that was pressed */ private void handleTabSelection(final ToggleButton pressed, final boolean notify) { final ObservableList<Node> siblings = buttons.getChildren(); int i = 0, selected_tab = -1; for (Node sibling : siblings) { final ToggleButton button = (ToggleButton) sibling; if (button == pressed) { // If user clicked a button that was already selected, // it would now be de-selected, leaving nothing selected. if (! pressed.isSelected()) { // Re-select! pressed.setSelected(true); } // Highlight active tab by setting it to the 'selected' color pressed.setStyle("-fx-color: " + JFXUtil.webRGB(selected)); selected_tab = i; } else if (button.isSelected()) { // Radio-button behavior: De-select other tabs button.setSelected(false); button.setStyle("-fx-color: " + JFXUtil.webRGB(deselected)); } ++i; } final Listener safe_copy = listener; if (selected_tab >= 0 && notify && safe_copy != null) safe_copy.tabSelected(selected_tab); }
Example 6
Source File: DynamicIconSupport.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Adds support changing icons by selection. * * @param button the button. */ @FxThread public static void addSupport(@NotNull final ToggleButton button) { final EditorConfig editorConfig = EditorConfig.getInstance(); final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME); if (!theme.needRepaintIcons()) { return; } final ImageView graphic = (ImageView) button.getGraphic(); final Image image = graphic.getImage(); final Image original = FILE_ICON_MANAGER.getOriginal(image); final ObservableMap<Object, Object> properties = button.getProperties(); properties.put(NOT_SELECTED_IMAGE, image); properties.put(SELECTED_IMAGE, original); button.selectedProperty().addListener((observable, oldValue, newValue) -> { if (newValue) { graphic.setImage((Image) properties.get(SELECTED_IMAGE)); } else { graphic.setImage((Image) properties.get(NOT_SELECTED_IMAGE)); } }); if (button.isSelected()) { graphic.setImage(original); } else { graphic.setImage(image); } }
Example 7
Source File: TerrainPaintingComponent.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Switch editing mode. */ @FxThread private void switchMode(@NotNull ToggleButton source) { if (!source.isSelected()) { source.setSelected(true); return; } getToggleButtons().forEach(source, (button, arg) -> button != arg, (toDeselect, arg) -> toDeselect.setSelected(false)); var category = notNull(getButtonToCategory().get(source)); showCategory(category); if (CATEGORY_PAINT.equals(category)) { FxUtils.addChild(this, getPaintControlSettings()); } else { FxUtils.removeChild(this, getPaintControlSettings()); } var toolControl = getButtonToControl().get(source); setToolControl(toolControl); if (!isShowed()) { return; } EXECUTOR_MANAGER.addJmeTask(() -> { var cursorNode = getCursorNode(); cursorNode.removeControl(TerrainToolControl.class); cursorNode.addControl(toolControl); }); }
Example 8
Source File: ListWidgetSelectorBehavior.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * An event filter to prevent the deselection of all buttons * * @param event The input event to be filtered */ private void eventFilter(ActionEvent event) { ToggleButton source = (ToggleButton) event.getSource(); if (source.getToggleGroup() == null || !source.isSelected()) { source.fire(); } }
Example 9
Source File: SidebarToggleGroupBaseSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * An event filter to prevent the deselection of all buttons * * @param event The input event to be filtered */ private static void eventFilter(ActionEvent event) { ToggleButton source = (ToggleButton) event.getSource(); if (source.getToggleGroup() == null || !source.isSelected()) { source.fire(); } }