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;
}
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();
}
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();
}
}
}
}
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);
}
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());
}
Aggregations