Java Code Examples for javafx.scene.control.ToggleButton#setSelected()
The following examples show how to use
javafx.scene.control.ToggleButton#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: ButtonCell.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public ButtonCell(TableColumn<T, Boolean> column, Glyph onGraphic, Glyph offGraphic) { button = new ToggleButton(); button.setGraphic(onGraphic); button.setSelected(true); button.setOnMouseClicked(event -> { final TableView<T> tableView = getTableView(); tableView.getSelectionModel().select(getTableRow().getIndex()); tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column); if (button.isSelected()) { commitEdit(true); button.setGraphic(onGraphic); } else { commitEdit(false); button.setGraphic(offGraphic); } }); }
Example 2
Source File: DisplayEditor.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private ToggleButton createToggleButton(final ActionDescription action) { final ToggleButton button = new ToggleButton(); try { button.setGraphic(ImageCache.getImageView(action.getIconResourcePath())); } catch (final Exception ex) { logger.log(Level.WARNING, "Cannot load action icon", ex); } button.setTooltip(new Tooltip(action.getToolTip())); button.setSelected(true); button.selectedProperty() .addListener((observable, old_value, enabled) -> action.run(this, enabled) ); return button; }
Example 3
Source File: ButtonCell.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public ButtonCell(TableColumn<T, Boolean> column, Glyph onGraphic, Glyph offGraphic) { button = new ToggleButton(); button.setGraphic(onGraphic); button.setSelected(true); button.setOnMouseClicked(event -> { final TableView<T> tableView = getTableView(); tableView.getSelectionModel().select(getTableRow().getIndex()); tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column); if (button.isSelected()) { commitEdit(true); button.setGraphic(onGraphic); } else { commitEdit(false); button.setGraphic(offGraphic); } }); }
Example 4
Source File: SceneFileEditor.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); lightButton = new ToggleButton(); lightButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SHOW_LIGHTS)); lightButton.setGraphic(new ImageView(Icons.LIGHT_16)); lightButton.setSelected(true); lightButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeLight(newValue)); audioButton = new ToggleButton(); audioButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SHOW_AUDIO)); audioButton.setGraphic(new ImageView(Icons.AUDIO_16)); audioButton.setSelected(true); audioButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeAudio(newValue)); DynamicIconSupport.addSupport(lightButton, audioButton); FXUtils.addClassesTo(lightButton, audioButton, CssClasses.FILE_EDITOR_TOOLBAR_BUTTON); FXUtils.addToPane(lightButton, container); FXUtils.addToPane(audioButton, container); }
Example 5
Source File: DisplayPositionSelector.java From Quelea with GNU General Public License v3.0 | 5 votes |
public void setTheme(ThemeDTO theme) { if (theme.getTextPosition() == -1) { for (ToggleButton button : buttons) { button.setSelected(false); } } else { buttons.get(theme.getTextPosition()).setSelected(true); } }
Example 6
Source File: ExerciseSlide.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
private ToggleButton addNoneButton() { final ToggleButton noneButton = (ToggleButton) exerciseItemPane.addButton(noneExercise, "None"); noneButton.setSelected(true); exerciseItemPane.setDefault(noneExercise); return noneButton; }
Example 7
Source File: ArenaBackgroundsSlide.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
private ButtonBase addNoneButton() { final LocatedImage none = new LocatedImage("/images/blank_page.png"); final InputStream isThumbnail = ArenaBackgroundsSlide.class.getResourceAsStream("/images/blank_page.png"); final ImageView thumbnailView = new ImageView(new Image(isThumbnail, 60, 60, true, true)); final ToggleButton noneButton = (ToggleButton) itemPane.addButton(none, "None", Optional.of(thumbnailView), Optional.empty()); noneButton.setSelected(true); itemPane.setDefault(none); return noneButton; }
Example 8
Source File: ToggleParameterSetEditor.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public void setValue(ValueType value) { if (value != null) { String stringValue = value.toString(); ObservableList<ToggleButton> buttons = segmentedButton.getButtons(); for (ToggleButton button : buttons) { if (button.getText().equals(stringValue)) { button.setSelected(true); break; } } } }
Example 9
Source File: ToggleEditor.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public void setValue(ValueType value) { if (value != null) { String stringValue = value.toString(); ObservableList<ToggleButton> buttons = segmentedButton.getButtons(); for (ToggleButton button : buttons) { if (button.getText().equals(stringValue)) { button.setSelected(true); break; } } } }
Example 10
Source File: BezierOffsetSnippet.java From gef with Eclipse Public License 2.0 | 5 votes |
public HBox ToggleButtonColor(String text, ObjectProperty<Color> colorProperty, BooleanProperty toggledProperty, boolean isToggled) { HBox hbox = new HBox(); ToggleButton toggleButton = new ToggleButton(text); toggleButton.setOnAction((ae) -> { refreshAll(); }); ColorPicker colorPicker = new ColorPicker(colorProperty.get()); colorProperty.bind(colorPicker.valueProperty()); hbox.getChildren().addAll(toggleButton, colorPicker); toggledProperty.bind(toggleButton.selectedProperty()); toggleButton.setSelected(isToggled); return hbox; }
Example 11
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 12
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 13
Source File: ImageToolbarHandler.java From phoebus with Eclipse Public License 1.0 | 4 votes |
/** @param item Tool item to select, all others will be de-selected */ private void selectMouseMode(final ToggleButton item) { for (ToggleButton ti : new ToggleButton[] { zoom_in, zoom_out, pan, pointer }) ti.setSelected(ti == item); }
Example 14
Source File: ToolbarHandler.java From phoebus with Eclipse Public License 1.0 | 4 votes |
/** @param item Tool item to select, all others will be de-selected */ private void selectMouseMode(final ToggleButton item) { for (ToggleButton ti : new ToggleButton[] { zoom_in, zoom_out, pan, pointer }) ti.setSelected(ti == item); }
Example 15
Source File: ToggleButtonSample.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { stage.setTitle("Toggle Button Sample"); stage.setWidth(250); stage.setHeight(180); HBox hbox = new HBox(); VBox vbox = new VBox(); Scene scene = new Scene(new Group(vbox)); stage.setScene(scene); scene.getStylesheets().add("togglebuttonsample/ControlStyle.css"); Rectangle rect = new Rectangle(); rect.setHeight(50); rect.setFill(Color.WHITE); rect.setStroke(Color.DARKGRAY); rect.setStrokeWidth(2); rect.setArcHeight(10); rect.setArcWidth(10); final ToggleGroup group = new ToggleGroup(); group.selectedToggleProperty().addListener((ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) -> { if (new_toggle == null) rect.setFill(Color.WHITE); else rect.setFill((Color) group.getSelectedToggle().getUserData()); }); ToggleButton tb1 = new ToggleButton("Minor"); tb1.setToggleGroup(group); tb1.setUserData(Color.LIGHTGREEN); tb1.setSelected(true); tb1.getStyleClass().add("toggle-button1"); ToggleButton tb2 = new ToggleButton("Major"); tb2.setToggleGroup(group); tb2.setUserData(Color.LIGHTBLUE); tb2.getStyleClass().add("toggle-button2"); ToggleButton tb3 = new ToggleButton("Critical"); tb3.setToggleGroup(group); tb3.setUserData(Color.SALMON); tb3.getStyleClass().add("toggle-button3"); hbox.getChildren().addAll(tb1, tb2, tb3); vbox.getChildren().add(new Label("Priority:")); vbox.getChildren().add(hbox); vbox.getChildren().add(rect); vbox.setPadding(new Insets(20, 10, 10, 20)); stage.show(); rect.setWidth(hbox.getWidth()); }
Example 16
Source File: TopBarView.java From erlyberly with GNU General Public License v3.0 | 4 votes |
private void invertSelection(ToggleButton toggleButton) { toggleButton.setSelected(!toggleButton.isSelected()); }
Example 17
Source File: MetadataOverview.java From sis with Apache License 2.0 | 4 votes |
public MetadataOverview(final DefaultMetadata md, final String fromFile) { this.metadata = md; this.fromFile = fromFile; VBox root = new VBox(); root.setStyle("-fx-background-color: linear-gradient(to bottom right, #aeb7c4, #fafafa);"); // Creation of the differents views. VBox summaryView = createSummaryView(); MetadataNode advancedView = new MetadataNode(md.asTreeTable()); advancedView.setMaxHeight(Double.MAX_VALUE); VBox.setVgrow(advancedView, Priority.ALWAYS); // Create and configure view selection buttons. ToggleGroup buttonGroup = new ToggleGroup(); ToggleButton tb1 = new ToggleButton("Summary"); ToggleButton tb2 = new ToggleButton("Advanced"); tb1.setStyle("-fx-text-fill: white; -fx-font-family: Arial Narrow;-fx-font-weight: bold; -fx-background-color: linear-gradient(#61a2b1, #2A5058); -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 ); -fx-padding: 0.8em;"); tb2.setStyle("-fx-text-fill: white; -fx-font-family: Arial Narrow;-fx-font-weight: bold; -fx-background-color: linear-gradient(#61a2b1, #2A5058); -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 ); -fx-padding: 0.8em;"); tb1.setToggleGroup(buttonGroup); tb1.setSelected(true); tb1.setDisable(true); tb2.setToggleGroup(buttonGroup); buttonGroup.selectToggle(tb1); buttonGroup.selectedToggleProperty().addListener((ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) -> { if (tb2.isSelected()) { tb2.setDisable(true); root.getChildren().remove(summaryView); root.getChildren().add(advancedView); tb1.setDisable(false); } else { tb1.setDisable(true); root.getChildren().add(summaryView); root.getChildren().remove(advancedView); tb2.setDisable(false); } }); HBox toggleGroupLayout = new HBox(); toggleGroupLayout.getChildren().addAll(tb1, tb2); toggleGroupLayout.setPadding(new Insets(0, 0, 10, 0)); root.getChildren().add(toggleGroupLayout); root.getChildren().add(summaryView); this.getChildren().add(root); }