javafx.scene.control.ToggleButton Java Examples

The following examples show how to use javafx.scene.control.ToggleButton. 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 vote down vote up
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: PaymentMethodForm.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void addAccountNameTextFieldWithAutoFillToggleButton() {
    Tuple3<Label, InputTextField, ToggleButton> tuple = addTopLabelInputTextFieldSlideToggleButton(gridPane, ++gridRow,
            Res.get("payment.account.name"), Res.get("payment.useCustomAccountName"));
    accountNameTextField = tuple.second;
    accountNameTextField.setPrefWidth(300);
    accountNameTextField.setEditable(false);
    accountNameTextField.setValidator(inputValidator);
    accountNameTextField.setFocusTraversable(false);
    accountNameTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        paymentAccount.setAccountName(newValue);
        updateAllInputsValid();
    });
    useCustomAccountNameToggleButton = tuple.third;
    useCustomAccountNameToggleButton.setSelected(false);
    useCustomAccountNameToggleButton.setOnAction(e -> {
        boolean selected = useCustomAccountNameToggleButton.isSelected();
        accountNameTextField.setEditable(selected);
        accountNameTextField.setFocusTraversable(selected);
        autoFillNameTextField();
    });
}
 
Example #3
Source File: ButtonCell.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
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: ToggleEditor.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
@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 #5
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, InputTextField, ToggleButton> addTopLabelInputTextFieldSlideToggleButton(GridPane gridPane,
                                                                                                     int rowIndex,
                                                                                                     String title,
                                                                                                     String toggleButtonTitle) {

    InputTextField inputTextField = new InputTextField();
    ToggleButton toggleButton = new JFXToggleButton();
    toggleButton.setText(toggleButtonTitle);
    VBox.setMargin(toggleButton, new Insets(4, 0, 0, 0));

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, 0);

    topLabelWithVBox.second.getChildren().add(toggleButton);

    return new Tuple3<>(topLabelWithVBox.first, inputTextField, toggleButton);
}
 
Example #6
Source File: ImageToolbarHandler.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private ButtonBase newItem(final boolean toggle, final ToolIcons icon, final String tool_tip)
  {
  	final ButtonBase item = toggle ? new ToggleButton() : new Button();
try
{
	item.setGraphic(new ImageView(Activator.getIcon(icon.name().toLowerCase())));
}
catch (Exception ex)
{
	logger.log(Level.WARNING, "Cannot get icon" + icon, ex);
	item.setText(icon.toString());
}
      item.setTooltip(new Tooltip(tool_tip));
      item.setMinSize(ToolbarHandler.BUTTON_WIDTH, ToolbarHandler.BUTTON_HEIGHT);

      toolbar.getItems().add(item);
      return item;
  }
 
Example #7
Source File: ActionUtils.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static ButtonBase createToolBarButton(Action action) {
	ButtonBase button = (action.selected != null) ? new ToggleButton() : new Button();
	button.setGraphic(FontAwesomeIconFactory.get().createIcon(action.icon, "1.2em"));
	String tooltip = action.text;
	if (tooltip.endsWith("..."))
		tooltip = tooltip.substring(0, tooltip.length() - 3);
	if (action.accelerator != null)
		tooltip += " (" + action.accelerator.getDisplayText() + ')';
	button.setTooltip(new Tooltip(tooltip));
	button.setFocusTraversable(false);
	if (action.action != null)
		button.setOnAction(action.action);
	if (action.disable != null)
		button.disableProperty().bind(action.disable);
	if (action.selected != null)
		((ToggleButton)button).selectedProperty().bindBidirectional(action.selected);
	return button;
}
 
Example #8
Source File: ListWidgetSelectorSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    ToggleGroup toggleGroup = new ToggleGroup();

    this.iconsListButton = new ToggleButton();
    this.iconsListButton.setToggleGroup(toggleGroup);
    this.iconsListButton.getStyleClass().addAll("listIcon", "iconsList");

    this.compactListButton = new ToggleButton();
    this.compactListButton.setToggleGroup(toggleGroup);
    this.compactListButton.getStyleClass().addAll("listIcon", "compactList");

    this.detailsListButton = new ToggleButton();
    this.detailsListButton.setToggleGroup(toggleGroup);
    this.detailsListButton.getStyleClass().addAll("listIcon", "detailsList");

    HBox container = new HBox(iconsListButton, compactListButton, detailsListButton);
    container.getStyleClass().add("listChooser");

    getChildren().addAll(container);
}
 
Example #9
Source File: ButtonCell.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
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 #10
Source File: DisplayEditor.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
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 #11
Source File: TerrainPaintingComponent.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * 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: ContainersSidebarToggleGroupSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Optional<ToggleButton> createAllButton() {
    final ToggleButton allCategoryButton = createSidebarToggleButton(tr("All"));

    allCategoryButton.getStyleClass().add("containerButton");
    allCategoryButton.setOnMouseClicked(event -> getControl().setNothingSelected());

    return Optional.of(allCategoryButton);
}
 
Example #13
Source File: FxAction.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public void attach(ButtonBase b)
{
	b.setOnAction(this);
	b.disableProperty().bind(disabledProperty());

	if(b instanceof ToggleButton)
	{
		((ToggleButton)b).selectedProperty().bindBidirectional(selectedProperty());
	}
}
 
Example #14
Source File: BezierOffsetSnippet.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
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 #15
Source File: Main.java    From youtube-comment-suite with MIT License 5 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    logger.debug("Initialize Main");

    headerToggleGroup.getToggles().addListener((ListChangeListener<Toggle>) c -> {
        while (c.next()) {
            for (final Toggle addedToggle : c.getAddedSubList()) {
                ((ToggleButton) addedToggle).addEventFilter(MouseEvent.MOUSE_RELEASED, mouseEvent -> {
                    if (addedToggle.equals(headerToggleGroup.getSelectedToggle()))
                        mouseEvent.consume();
                });
            }
        }
    });

    settingsIcon.setImage(ImageLoader.SETTINGS.getImage());
    btnSettings.setOnAction(ae -> runLater(() -> {
        logger.debug("Open Settings");
        settings.setManaged(true);
        settings.setVisible(true);
    }));

    btnSearchComments.setOnAction(ae -> runLater(() -> {
        headerIcon.setImage(ImageLoader.SEARCH.getImage());
        content.getChildren().clear();
        content.getChildren().add(searchComments);
    }));
    btnManageGroups.setOnAction(ae -> runLater(() -> {
        headerIcon.setImage(ImageLoader.MANAGE.getImage());
        content.getChildren().clear();
        content.getChildren().add(manageGroups);
    }));
    btnSearchYoutube.setOnAction(ae -> runLater(() -> {
        headerIcon.setImage(ImageLoader.YOUTUBE.getImage());
        content.getChildren().clear();
        content.getChildren().add(searchYoutube);
    }));

    btnManageGroups.fire();
}
 
Example #16
Source File: ColorChooser.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
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 #17
Source File: SidebarToggleGroupBaseSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #18
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static ToggleButton addSlideToggleButton(GridPane gridPane, int rowIndex, String title, double top) {
    ToggleButton toggleButton = new AutoTooltipSlideToggleButton();
    toggleButton.setText(title);
    GridPane.setRowIndex(toggleButton, rowIndex);
    GridPane.setColumnIndex(toggleButton, 0);
    GridPane.setMargin(toggleButton, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(toggleButton);

    return toggleButton;
}
 
Example #19
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Adds support changing icons by selection.
 *
 * @param buttons the buttons.
 */
@FxThread
public static void addSupport(@NotNull final ToggleButton... buttons) {
    for (final ToggleButton button : buttons) {
        addSupport(button);
    }
}
 
Example #20
Source File: NavigationTabs.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Select a tab
 *
 *  <p>Does not invoke listener.
 *
 *  @param index Index of tab to select */
public void selectTab(int index)
{
    final ObservableList<Node> siblings = buttons.getChildren();
    if (index < 0)
        index = 0;
    if (index >= siblings.size())
        index = siblings.size() - 1;
    if (index < 0)
        return; // No buttons, index is -1
    handleTabSelection((ToggleButton)siblings.get(index), false);
}
 
Example #21
Source File: DiagramTabToolBar.java    From JetUML with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the selected tool to be the one at pIndex (zero-indexed)
 * in the tool group. Does nothing if there is no tool at this index.
 * 
 * @param pIndex The desired index.
 */
public void setSelectedTool(int pIndex)
{
	ToggleGroup group = ((ToggleButton)getItems().get(0)).getToggleGroup();
	if( pIndex < 0 || pIndex >= group.getToggles().size())
	{
		return;
	}
	group.getToggles().get(pIndex).setSelected(true);
}
 
Example #22
Source File: ContainersSidebarToggleGroupSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ToggleButton convertToToggleButton(ContainerCategoryDTO category) {
    final ToggleButton containerButton = createSidebarToggleButton(category.getName());

    containerButton.getStyleClass().add("containerButton");
    containerButton.setOnMouseClicked(event -> getControl().setSelectedElement(category));

    return containerButton;
}
 
Example #23
Source File: LibrarySidebarToggleGroupSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ToggleButton convertToToggleButton(ShortcutCategoryDTO category) {
    final ToggleButton categoryButton = createSidebarToggleButton(category.getName());
    // TODO: store category ID in shortcut.info?
    categoryButton.setId(LibrarySidebarToggleGroupSkin.getToggleButtonId(category.getId()));
    categoryButton.setOnMouseClicked(event -> getControl().setSelectedElement(category));

    return categoryButton;
}
 
Example #24
Source File: ArenaBackgroundsSlide.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: TradesChartsView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private HBox getToolBox() {

        final Tuple3<VBox, Label, AutocompleteComboBox<CurrencyListItem>> currencyComboBoxTuple = addTopLabelAutocompleteComboBox(
                Res.get("shared.currency"));
        currencyComboBox = currencyComboBoxTuple.third;
        currencyComboBox.setCellFactory(GUIUtil.getCurrencyListItemCellFactory(Res.get("shared.trade"),
                Res.get("shared.trades"), model.preferences));

        Pane spacer = new Pane();
        HBox.setHgrow(spacer, Priority.ALWAYS);

        toggleGroup = new ToggleGroup();
        ToggleButton year = getToggleButton(Res.get("time.year"), TradesChartsViewModel.TickUnit.YEAR, toggleGroup, "toggle-left");
        ToggleButton month = getToggleButton(Res.get("time.month"), TradesChartsViewModel.TickUnit.MONTH, toggleGroup, "toggle-center");
        ToggleButton week = getToggleButton(Res.get("time.week"), TradesChartsViewModel.TickUnit.WEEK, toggleGroup, "toggle-center");
        ToggleButton day = getToggleButton(Res.get("time.day"), TradesChartsViewModel.TickUnit.DAY, toggleGroup, "toggle-center");
        ToggleButton hour = getToggleButton(Res.get("time.hour"), TradesChartsViewModel.TickUnit.HOUR, toggleGroup, "toggle-center");
        ToggleButton minute10 = getToggleButton(Res.get("time.minute10"), TradesChartsViewModel.TickUnit.MINUTE_10, toggleGroup, "toggle-right");

        HBox toggleBox = new HBox();
        toggleBox.setSpacing(0);
        toggleBox.setAlignment(Pos.CENTER_LEFT);
        toggleBox.getChildren().addAll(year, month, week, day, hour, minute10);

        final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(Res.get("shared.interval"), toggleBox);

        HBox hBox = new HBox();
        hBox.setSpacing(0);
        hBox.setAlignment(Pos.CENTER_LEFT);
        hBox.getChildren().addAll(currencyComboBoxTuple.first, spacer, topLabelWithVBox.second);
        return hBox;
    }
 
Example #26
Source File: BooleanWidgetPropertyBinding.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public BooleanWidgetPropertyBinding(final UndoableActionManager undo,
                                    final CheckBox check, final ComboBox<String> field,
                                    final ToggleButton macroButton,
                                    final BooleanWidgetProperty widget_property,
                                    final List<Widget> other)
{
    super(undo, field, widget_property, other);
    this.check = check;
    this.macroButton = macroButton;
}
 
Example #27
Source File: Palette.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** De-select buttons
 *  @param keep The one button to keep (or <code>null</code>)
 */
private void deselectButtons(final ToggleButton keep)
{
    // De-select all buttons
    for (Pane pane : groups)
        for (Node other : pane.getChildren())
            if (other instanceof ToggleButton  &&
                other != keep)
                ((ToggleButton)other).setSelected(false);
}
 
Example #28
Source File: Palette.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Create entry for each widget type
  * @param palette_groups Map with parent panes for each widget category
 */
private void createWidgetEntries(final Map<WidgetCategory, Pane> palette_groups)
{
    final Set<String> deprecated = Preferences.hidden_widget_types;

    //  Sort alphabetically-case-insensitive widgets inside their group
    //  based on the widget's name, instead of the original set order or class name.
    WidgetFactory.getInstance()
                 .getWidgetDescriptions()
                 .stream()
                 .filter(desc -> !deprecated.contains(desc.getType()))
                 .sorted((d1,d2) -> String.CASE_INSENSITIVE_ORDER.compare(d1.getName(), d2.getName()))
                 .forEach(desc ->
   {
        final ToggleButton button = new ToggleButton(desc.getName());

        final Image icon = WidgetIcons.getIcon(desc.getType());
        if (icon != null)
            button.setGraphic(new ImageView(icon));

        button.setPrefWidth(PREFERRED_WIDTH);
        button.setAlignment(Pos.BASELINE_LEFT);
        button.setTooltip(new Tooltip(desc.getDescription()));
        button.setOnAction(event ->
        {
            // Remember the widget-to-create via rubberband
            active_widget_type = desc;

            // De-select all _other_ buttons
            deselectButtons(button);
        });

        palette_groups.get(desc.getCategory()).getChildren().add(button);
        WidgetTransfer.addDragSupport(button, editor, this, desc, icon);
    });
}
 
Example #29
Source File: NavigationTabs.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** 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 #30
Source File: ListWidgetSelectorBehavior.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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();
    }
}