Java Code Examples for javafx.scene.control.ToggleButton#setOnAction()
The following examples show how to use
javafx.scene.control.ToggleButton#setOnAction() .
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: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 9 votes |
private ToggleButton setupButton(ToggleGroup group, ComponentLauncherInfo componentInfo) { ToggleButton button = new ToggleButton(componentInfo.name.getValue(), setupImageView(componentInfo.image)); button.setAlignment(Pos.CENTER_LEFT); button.setToggleGroup(group); button.setMinHeight(30); button.setMaxWidth(Double.MAX_VALUE); button.setOnAction(e -> { if(button.isSelected()) { modifiedSelection(componentInfo); } else { modifiedSelection(null); } }); GridPane.setHgrow(button, Priority.ALWAYS); return button; }
Example 2
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 3
Source File: FlyoutDemo.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Creates and returns a {@link Flyout} * @return a new {@link Flyout} */ public Flyout createFlyout() { stuffChooserTrigger = new ToggleButton("Create / Select Item"); stuffChooserTrigger.setOnAction(e -> { if(stuffChooserTrigger.isSelected()) { flyout.flyout(); }else{ flyout.dismiss(); } }); Flyout retVal = new Flyout(stuffChooserTrigger, getStuffControl(), null); return retVal; }
Example 4
Source File: ApplicationSidebarToggleGroupSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Optional<ToggleButton> createAllButton() { final ToggleButton allCategoryButton = createSidebarToggleButton(tr("All")); allCategoryButton.setId("all-button"); allCategoryButton.setOnAction(event -> getControl().setNothingSelected()); return Optional.of(allCategoryButton); }
Example 5
Source File: ApplicationSidebarToggleGroupSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected ToggleButton convertToToggleButton(CategoryDTO category) { final ToggleButton categoryButton = createSidebarToggleButton(category.getName()); categoryButton.setId(ApplicationSidebarToggleGroupSkin.getToggleButtonId(category.getId())); categoryButton.setOnAction(event -> getControl().setSelectedElement(category)); return categoryButton; }
Example 6
Source File: SettingsSidebarToggleGroupSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected ToggleButton convertToToggleButton(SettingsSidebarItem item) { final ToggleButton toggleButton = createSidebarToggleButton(item.getName()); toggleButton.getStyleClass().add(item.getIconClass()); toggleButton.setOnAction(event -> getControl().setSelectedElement(item)); return toggleButton; }
Example 7
Source File: EnginesSidebarToggleGroupSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected ToggleButton convertToToggleButton(EngineCategoryDTO category) { final ToggleButton categoryButton = createSidebarToggleButton(category.getName()); // TODO: use engine category ID instead of name categoryButton .setId(String.format("engines-%s", SidebarToggleGroupBaseSkin.getToggleButtonId(category.getName()))); categoryButton.setOnAction(event -> getControl().setSelectedElement(category)); return categoryButton; }
Example 8
Source File: ColorChooser.java From LogFX with GNU General Public License v3.0 | 5 votes |
public ColorChooser( String initialColor, String tooltipText ) { this.colorPicker = new ColorPicker(); colorPicker.setTooltip( new Tooltip( tooltipText ) ); box = new HBox( 2 ); try { colorPicker.setValue( Color.valueOf( initialColor ) ); } catch ( IllegalArgumentException e ) { log.warn( "Unable to set color picker's initial color to invalid color: {}", initialColor ); } manualEditor = new ManualEditor( colorPicker.getValue(), tooltipText, colorPicker::setValue ); addListener( ( observable -> { // only update the text if the currently visible control is the color picker if ( box.getChildren().get( 0 ) == colorPicker ) { manualEditor.colorField.setText( colorPicker.getValue().toString() ); } } ) ); ToggleButton editButton = AwesomeIcons.createToggleButton( AwesomeIcons.PENCIL, 10 ); box.getChildren().addAll( colorPicker, editButton ); editButton.setOnAction( event -> { ObservableList<Node> children = box.getChildren(); if ( children.get( 0 ) == manualEditor ) { box.getChildren().set( 0, colorPicker ); } else { box.getChildren().set( 0, manualEditor ); manualEditor.colorField.requestFocus(); manualEditor.colorField.selectAll(); } } ); }
Example 9
Source File: RichTextDemo.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
private ToggleButton createToggleButton(ToggleGroup grp, String styleClass, Runnable action, String toolTip) { ToggleButton button = new ToggleButton(); button.setToggleGroup(grp); button.getStyleClass().add(styleClass); button.setOnAction(evt -> { action.run(); area.requestFocus(); }); button.setPrefWidth(25); button.setPrefHeight(25); if (toolTip != null) { button.setTooltip(new Tooltip(toolTip)); } return button; }
Example 10
Source File: AbstractSimpleAction.java From marathonv5 with Apache License 2.0 | 4 votes |
public ToggleButton getToggleButton() { ToggleButton toggleButton = FXUIUtils.createToggleButton(name, description); toggleButton.setOnAction(this); return toggleButton; }
Example 11
Source File: PVTree.java From phoebus with Eclipse Public License 1.0 | 4 votes |
public Node create() { final Label label = new Label(Messages.PV_Label); pv_name.setOnAction(event -> setPVName(pv_name.getText())); pv_name.setTooltip(new Tooltip(Messages.PV_TT)); PVAutocompleteMenu.INSTANCE.attachField(pv_name); final ToggleButton latch = new ToggleButton(null, getImageView("run.png")); latch.setTooltip(new Tooltip(Messages.LatchTT)); latch.setOnAction(event -> { tree.getModel().latchOnAlarm(latch.isSelected()); if (latch.isSelected()) latch.setGraphic(getImageView("pause_on_alarm.png")); else latch.setGraphic(getImageView("run.png")); }); final Button collapse = new Button(null, getImageView("collapse.gif")); collapse.setTooltip(new Tooltip(Messages.CollapseTT)); collapse.setOnAction(event -> tree.expandAll(false)); final Button alarms = new Button(null, getImageView("alarmtree.png")); alarms.setTooltip(new Tooltip(Messages.ExpandAlarmsTT)); alarms.setOnAction(event -> tree.expandAlarms()); final Button expand = new Button(null, getImageView("pvtree.png")); expand.setTooltip(new Tooltip(Messages.ExpandAllTT)); expand.setOnAction(event -> tree.expandAll(true)); // center vertically label.setMaxHeight(Double.MAX_VALUE); HBox.setHgrow(pv_name, Priority.ALWAYS); final HBox top = new HBox(5, label, pv_name, latch, collapse, alarms, expand); BorderPane.setMargin(top, new Insets(5, 5, 0, 5)); BorderPane.setMargin(tree.getNode(), new Insets(5)); final BorderPane layout = new BorderPane(tree.getNode()); layout.setTop(top); hookDragDrop(layout); return layout; }
Example 12
Source File: TerrainPaintingComponent.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@Override @FxThread protected void createComponents() { raiseLowerButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_UP_32)); raiseLowerButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); smoothButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_SMOOTH_32)); smoothButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); roughButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_ROUGH_32)); roughButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); levelButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_LEVEL_32)); levelButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); slopeButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_SLOPE_32)); slopeButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); paintButton = new ToggleButton(StringUtils.EMPTY, new ImageView(Icons.TERRAIN_PAINT_32)); paintButton.setOnAction(event -> switchMode((ToggleButton) event.getSource())); var buttonsContainer = new GridPane(); buttonsContainer.setAlignment(Pos.CENTER); buttonsContainer.setPadding(new Insets(2, 4, 2, 4)); buttonsContainer.add(raiseLowerButton, 0, 0); buttonsContainer.add(smoothButton, 1, 0); buttonsContainer.add(roughButton, 2, 0); buttonsContainer.add(levelButton, 3, 0); buttonsContainer.add(slopeButton, 4, 0); buttonsContainer.add(paintButton, 5, 0); buttonsContainer.prefWidthProperty().bind(widthProperty()); FxUtils.addChild(this, buttonsContainer); super.createComponents(); createPaintControlSettings(); FxUtils.addClass(raiseLowerButton, smoothButton, roughButton, CssClasses.MEDIUM_TOGGLE_BUTTON) .addClass(levelButton, slopeButton, paintButton, CssClasses.MEDIUM_TOGGLE_BUTTON) .addClass(buttonsContainer, CssClasses.DEF_GRID_PANE); }
Example 13
Source File: ToggleParameterSetEditor.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("unchecked") public ToggleParameterSetEditor(PropertySheet.Item parameter) { if (!(parameter instanceof ToggleParameterSetParameter)) throw new IllegalArgumentException(); this.toggleParameterSetParameter = (ToggleParameterSetParameter<ValueType>) parameter; // The segmented button this.segmentedButton = new SegmentedButton(); segmentedButton.getStyleClass().add(SegmentedButton.STYLE_CLASS_DARK); // The toggle buttons toggleValues = this.toggleParameterSetParameter.getToggleValues(); for (HashMap.Entry<String, ParameterSet> entry : toggleValues.entrySet()) { ToggleButton toggleButton = new ToggleButton(entry.getKey()); // When toggle button is selected, show corresponding parameters toggleButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* * TODO Show parameters when button is selected */ System.out.println("Toggle button selected: " + entry.getKey()); System.out.println("Parameter set: " + entry.getValue()); ParameterSheetView parameterSheetView = new ParameterSheetView(entry.getValue(), null); ParameterSet currentParameterSet = MZmineCore.getConfiguration().getModuleParameters(CsvExportModule.class); // ParameterSetupDialog dialog = new // ParameterSetupDialog(entry.getValue(), null); // dialog.showAndWait(); } }); segmentedButton.getButtons().add(toggleButton); } setLeft(segmentedButton); }
Example 14
Source File: BreakingNewsDemoView.java From htm.java-examples with GNU Affero General Public License v3.0 | 4 votes |
/** * Demonstrates the construction and usage of the {@link SegmentedButtonBar} * @return */ public HBox createSegmentedButtonBar() { ToggleButton button1 = new ToggleButton("Start"); button1.getStyleClass().addAll("first"); button1.setOnAction(e -> { Platform.runLater(() -> { if(mode == Mode.MANUAL) { runOneBtn.setDisable(false); } startActionProperty.set(true); }); }); ToggleButton button2 = new ToggleButton("Stop"); button2.getStyleClass().addAll("last"); button2.setOnAction(e -> { Platform.runLater(() -> { startActionProperty.set(false); }); }); ToggleButton button3 = new ToggleButton("Auto"); button3.getStyleClass().addAll("first"); button3.setOnAction(e -> { Platform.runLater(() -> { mode = Mode.AUTO; autoModeProperty.set(mode); }); }); ToggleButton button4 = new ToggleButton("Manual"); button4.getStyleClass().addAll("last"); button4.setOnAction(e -> { Platform.runLater(() -> { mode = Mode.MANUAL; autoModeProperty.set(mode); }); }); Button button5 = runOneBtn = new Button("Run One"); button5.getStyleClass().addAll("only"); button5.setDisable(true); button5.setOnAction(e -> { Platform.runLater(() -> { runOneProperty.set(runOneProperty.get() + 1); }); }); runDisableProperty.addListener((v, o, n) -> { button5.setDisable(n); }); ToggleGroup group = new ToggleGroup(); group.getToggles().addAll(button1, button2); group.selectToggle(button2); ToggleGroup group2 = new ToggleGroup(); group2.getToggles().addAll(button3, button4); group2.selectToggle(button3); group2.selectedToggleProperty().addListener((v, o, n) -> { if(n == null) return; if(n.equals(button4)) { Platform.runLater(() -> { mode = Mode.MANUAL; group.selectToggle(button2); startActionProperty.set(false); }); }else{ Platform.runLater(() -> { mode = Mode.AUTO; startActionProperty.set(false); group.selectToggle(button2); button5.setDisable(true); }); } }); HBox displayBox = new HBox(); displayBox.setSpacing(20); displayBox.setAlignment(Pos.CENTER); SegmentedButtonBar buttonBar = new SegmentedButtonBar(); buttonBar.getChildren().addAll(button1, button2); SegmentedButtonBar buttonBar2 = new SegmentedButtonBar(); buttonBar2.getChildren().addAll(button3, button4); SegmentedButtonBar buttonBar3 = new SegmentedButtonBar(); buttonBar3.getChildren().addAll(button5); displayBox.getChildren().addAll(buttonBar, buttonBar2, buttonBar3); return displayBox; }