Search in sources :

Example 11 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project FXGL by AlmasB.

the class GTAVMenu method makeMenuBar.

private HBox makeMenuBar() {
    ToggleButton tb1 = new ToggleButton("MAIN MENU");
    ToggleButton tb2 = new ToggleButton("OPTIONS");
    ToggleButton tb3 = new ToggleButton("EXTRA");
    tb1.setFont(FXGL.getUIFactory().newFont(18));
    tb2.setFont(FXGL.getUIFactory().newFont(18));
    tb3.setFont(FXGL.getUIFactory().newFont(18));
    ToggleGroup group = new ToggleGroup();
    tb1.setToggleGroup(group);
    tb2.setToggleGroup(group);
    tb3.setToggleGroup(group);
    tb1.setUserData(menuBody);
    tb2.setUserData(makeOptionsMenu());
    tb3.setUserData(makeExtraMenu());
    group.selectedToggleProperty().addListener((obs, old, newToggle) -> {
        if (newToggle == null) {
            group.selectToggle(old);
            return;
        }
        switchMenuTo((Node) newToggle.getUserData());
    });
    group.selectToggle(tb1);
    HBox hbox = new HBox(10, tb1, tb2, tb3);
    hbox.setAlignment(Pos.TOP_CENTER);
    return hbox;
}
Also used : ToggleButton(javafx.scene.control.ToggleButton) HBox(javafx.scene.layout.HBox) ToggleGroup(javafx.scene.control.ToggleGroup)

Example 12 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project JFoenix by jfoenixadmin.

the class RadioButtonDemo method start.

@Override
public void start(Stage primaryStage) {
    final ToggleGroup group = new ToggleGroup();
    JFXRadioButton javaRadio = new JFXRadioButton("JavaFX");
    javaRadio.setPadding(new Insets(10));
    javaRadio.setToggleGroup(group);
    JFXRadioButton jfxRadio = new JFXRadioButton("JFoenix");
    jfxRadio.setPadding(new Insets(10));
    jfxRadio.setToggleGroup(group);
    VBox vbox = new VBox();
    vbox.getChildren().add(javaRadio);
    vbox.getChildren().add(jfxRadio);
    vbox.setSpacing(10);
    HBox hbox = new HBox();
    hbox.getChildren().add(vbox);
    hbox.setSpacing(50);
    hbox.setPadding(new Insets(40, 10, 10, 120));
    Scene scene = new Scene(hbox);
    primaryStage.setScene(scene);
    primaryStage.setWidth(500);
    primaryStage.setHeight(400);
    primaryStage.setTitle("JFX RadioButton Demo ");
    scene.getStylesheets().add(RadioButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    primaryStage.show();
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) ToggleGroup(javafx.scene.control.ToggleGroup) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 13 with ToggleGroup

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

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 14 with ToggleGroup

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

the class ListWidgetSelectorSkin method initialise.

/**
 * {@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);
}
Also used : ToggleButton(javafx.scene.control.ToggleButton) HBox(javafx.scene.layout.HBox) ToggleGroup(javafx.scene.control.ToggleGroup)

Example 15 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project VocabHunter by VocabHunter.

the class FilterSessionController method buildToggleGroup.

private void buildToggleGroup(final FilterFileModel parentModel, final FilterSessionModel filterModel) {
    ToggleGroup toggleGroup = new ToggleGroup();
    buttonKnown.setToggleGroup(toggleGroup);
    buttonSeen.setToggleGroup(toggleGroup);
    boolean isIncludeUnknown = parentModel.getMode() == FilterFileMode.SESSION_SEEN;
    buttonKnown.setSelected(!isIncludeUnknown);
    buttonSeen.setSelected(isIncludeUnknown);
    filterModel.includeUnknownProperty().bind(buttonSeen.selectedProperty());
}
Also used : ToggleGroup(javafx.scene.control.ToggleGroup)

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