Search in sources :

Example 31 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project POL-POM-5 by PhoenicisOrg.

the class SidebarToggleGroupBehavior method selectFirstToggleButton.

/**
 * Ensures, that always a button is selected:
 * - if because of an invalidation of the input list the selection is lost, the selection is reapplied
 * - if no button is selected, select the first button
 */
private void selectFirstToggleButton() {
    final ToggleGroup toggleGroup = getSkin().getToggleGroup();
    if (toggleGroup.getSelectedToggle() == null && !toggleGroup.getToggles().isEmpty()) {
        final E selectedElement = getControl().selectedElementProperty().getValue();
        if (selectedElement != null && getControl().getElements().contains(selectedElement)) {
            // 1 if an "all" button exists, 0 otherwise
            final int offset = toggleGroup.getToggles().size() - getControl().getElements().size();
            final int index = getControl().getElements().indexOf(getControl().selectedElementProperty().getValue());
            // reselect the previously selected item
            toggleGroup.selectToggle(toggleGroup.getToggles().get(offset + index));
        } else {
            final Toggle firstToggle = toggleGroup.getToggles().get(0);
            // trigger the first item in the toggle group
            if (firstToggle instanceof ToggleButton) {
                ((ToggleButton) firstToggle).fire();
            }
        }
    }
}
Also used : ToggleButton(javafx.scene.control.ToggleButton) ToggleGroup(javafx.scene.control.ToggleGroup) Toggle(javafx.scene.control.Toggle)

Example 32 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project Board-Instrumentation-Framework by intel.

the class Demo method initBack.

private Pane initBack(final FlipPanel flipPanel, final StackPane FRONT_PANEL) {
    Region backButton = new Region();
    backButton.getStyleClass().add("back-button");
    backButton.addEventHandler(MouseEvent.MOUSE_CLICKED, EVENT -> flipPanel.flipToFront());
    ToggleGroup group = new ToggleGroup();
    final RadioButton standardGreen = new RadioButton("Green");
    standardGreen.setToggleGroup(group);
    standardGreen.setSelected(true);
    standardGreen.setOnAction(event -> FRONT_PANEL.setBackground(new Background(new BackgroundFill(Color.GREEN, CornerRadii.EMPTY, Insets.EMPTY))));
    final RadioButton amber = new RadioButton("Red");
    amber.setToggleGroup(group);
    amber.setOnAction(event -> FRONT_PANEL.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY))));
    final RadioButton blueDarkBlue = new RadioButton("Blue");
    blueDarkBlue.setToggleGroup(group);
    blueDarkBlue.setOnAction(event -> FRONT_PANEL.setBackground(new Background(new BackgroundFill(Color.BLUE, CornerRadii.EMPTY, Insets.EMPTY))));
    VBox componentsBack = new VBox(backButton, standardGreen, amber, blueDarkBlue);
    componentsBack.setSpacing(10);
    StackPane back = new StackPane();
    back.setPadding(new Insets(20, 20, 20, 20));
    back.getStyleClass().add("panel");
    back.getChildren().addAll(componentsBack);
    return back;
}
Also used : Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) ToggleGroup(javafx.scene.control.ToggleGroup) BackgroundFill(javafx.scene.layout.BackgroundFill) Region(javafx.scene.layout.Region) RadioButton(javafx.scene.control.RadioButton) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Aggregations

ToggleGroup (javafx.scene.control.ToggleGroup)32 Insets (javafx.geometry.Insets)10 RadioButton (javafx.scene.control.RadioButton)9 HBox (javafx.scene.layout.HBox)9 ToggleButton (javafx.scene.control.ToggleButton)8 Label (javafx.scene.control.Label)7 VBox (javafx.scene.layout.VBox)6 Toggle (javafx.scene.control.Toggle)5 Button (javafx.scene.control.Button)4 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)3 Scene (javafx.scene.Scene)3 AutoTooltipRadioButton (bisq.desktop.components.AutoTooltipRadioButton)2 BsqReceiveView (bisq.desktop.main.dao.wallet.receive.BsqReceiveView)2 Popup (bisq.desktop.main.overlays.popups.Popup)2 List (java.util.List)2 FXCollections (javafx.collections.FXCollections)2 Node (javafx.scene.Node)2 CheckBox (javafx.scene.control.CheckBox)2 ComboBox (javafx.scene.control.ComboBox)2 MenuItem (javafx.scene.control.MenuItem)2