@Override public void start(Stage stage) throws Exception { final VBox pane = new VBox(); pane.setSpacing(30); pane.setStyle("-fx-background-color:#EEE; -fx-padding: 40;"); ToggleButton button = new ToggleButton("JavaFx Toggle"); pane.getChildren().add(button); JFXToggleButton toggleButton = new JFXToggleButton(); toggleButton.setText("New Skin"); pane.getChildren().add(toggleButton); JFXToggleNode node = new JFXToggleNode(); final GlyphIcon heartIcon = GlyphsBuilder.create(FontAwesomeIconView.class) .glyph(FontAwesomeIcon.HEART) .build(); heartIcon.setStyle("-fx-padding: 10"); node.setGraphic(heartIcon); pane.getChildren().add(node); final Scene scene = new Scene(pane, 600, 400, Color.valueOf("#EEE")); stage.setTitle("JFX Toggle Button Demo "); scene.getStylesheets() .add(ToggleButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setScene(scene); stage.setResizable(false); stage.show(); }
/** * Takes the provided {@link Action} and returns a {@link ToggleButton} instance * with all relevant properties bound to the properties of the Action. * * @param action The {@link Action} that the {@link ToggleButton} should bind to. * @param textBehavior Defines {@link ActionTextBehavior} * @return A {@link ToggleButton} that is bound to the state of the provided * {@link Action} */ public static ToggleButton createToggleButton(final Action action, final ActionTextBehavior textBehavior ) { return configure(new ToggleButton(), action, textBehavior); }
/** * Creates a new {@link ToggleButton} for the sidebar. * This new toggle button is initialised with the necessary style classes * * @param text The text shown on the new toggle button * @return The created toggle button */ protected static ToggleButton createSidebarToggleButton(String text) { final ToggleButton toggleButton = new ToggleButton(text); toggleButton.getStyleClass().add("sidebarButton"); toggleButton.addEventFilter(ActionEvent.ANY, SidebarToggleGroupBaseSkin::eventFilter); return toggleButton; }
public ToggleButton createIconToggleButton(GlyphIcons icon, String text, String iconSize, String fontSize, ContentDisplay contentDisplay) { Text label = createIcon(icon, iconSize); ToggleButton button = new ToggleButton(text); button.setStyle("-fx-font-size: " + fontSize); button.setGraphic(label); button.setContentDisplay(contentDisplay); return button; }
/** * {@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); }
for (int i = 0; i < 31; i++) { final int day = i + 1; final ToggleButton button = new ToggleButton(decimalFormat.format(day)); button.setOnAction(new EventHandler<ActionEvent>() { @Override
/** * {@inheritDoc} */ @Override protected void initView() { super.initView(); node().setStyle("-fx-background-color:white"); node().setPadding(new Insets(10, 20, 10, 20)); node().setSpacing(40); node().setAlignment(Pos.CENTER); this.summary = new Label("0 item left"); HBox.setMargin(this.summary, new Insets(10, 80, 10, 10)); this.group = new ToggleGroup(); this.all = new ToggleButton("All"); this.all.setUserData(FilterKind.All); this.all.setToggleGroup(this.group); this.active = new ToggleButton("Active"); this.active.setUserData(FilterKind.Undone); this.active.setToggleGroup(this.group); this.completed = new ToggleButton("Done"); this.completed.setUserData(FilterKind.Done); this.completed.setToggleGroup(this.group); this.all.setSelected(true); node().getChildren().addAll(this.summary, this.all, this.active, this.completed); }
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; }
FlowPane infoPane = new FlowPane(); buttonYear = new ToggleButton(org.openide.util.NbBundle.getMessage( CalendarComponent.class, "CalendarComponent.button.year")); buttonMonth = new ToggleButton(org.openide.util.NbBundle.getMessage( CalendarComponent.class, "CalendarComponent.button.month")); buttonWeek = new ToggleButton(org.openide.util.NbBundle.getMessage( CalendarComponent.class, "CalendarComponent.button.week")); buttonDay = new ToggleButton(org.openide.util.NbBundle.getMessage( CalendarComponent.class, "CalendarComponent.button.day")); buttonToday = new Button(org.openide.util.NbBundle.getMessage(
repeatProgressIndicator.setVisible(false); repeatProgressIndicator.progressProperty().bind(repeatFilterService.progressProperty()); final ToggleButton repeatToggleButton = new ToggleButton("", new ImageView(new Image(getClass().getResourceAsStream("/org/copperengine/gui/icon/repeat.png")))); final ToggleButton filterButton = new ToggleButton("", new ImageView(new Image(getClass().getResourceAsStream("/org/copperengine/gui/icon/filter.png")))); filterButton.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override
final ToggleButton b = new ToggleButton(tab.name());// , new ImageView(model().getBehavior(DockableBehavior.class).modelIcon())); b.setToggleGroup(this.group);
hbox.getChildren().add(b5); ToggleButton tb5 = new ToggleButton("ToggleButton"); AquaFx.resizeControl(tb5, ControlSizeVariant.REGULAR); hbox.getChildren().add(tb5);
expandCollapseButton = new ToggleButton(); expandCollapseButton.setMouseTransparent(true); expandCollapseButton.visibleProperty().bind(Bindings.not(control.showOnHoverProperty()));
ToggleButton sampleButton4 = new ToggleButton("TG1"); sampleButton4.setToggleGroup(toolbarGroup); sampleButton4.setSelected(true); AquaFx.createToggleButtonStyler().setType(ButtonType.LEFT_PILL).style(sampleButton4); ToggleButton sampleButton5 = new ToggleButton("TG2"); sampleButton5.setToggleGroup(toolbarGroup); sampleButton5.setSelected(true); AquaFx.createToggleButtonStyler().setType(ButtonType.CENTER_PILL).style(sampleButton5); ToggleButton sampleButton6 = new ToggleButton("TG3"); sampleButton6.setToggleGroup(toolbarGroup); sampleButton6.setSelected(true); ToggleButton sampleButton1 = new ToggleButton("Toggle"); sampleButton1.setDisable(true); ToggleButton sampleButton2 = new ToggleButton("Toggle"); ToggleButton sampleButton3 = new ToggleButton("Toggle2"); sampleButton3.setSelected(true); toolBar.getItems().addAll(colorTB, sampleButton, sampleButton1, sampleButton2, sampleButton3, seperateIt, sampleButton4, HBox toggleGroupBox = new HBox(); ToggleGroup group = new ToggleGroup(); ToggleButton tb1 = new ToggleButton("First"); tb1.setToggleGroup(group); tb1.setSelected(true); AquaFx.createToggleButtonStyler().setType(ButtonType.LEFT_PILL).style(tb1); toggleGroupBox.getChildren().add(tb1); ToggleButton tb2 = new ToggleButton("Second"); tb2.setToggleGroup(group); AquaFx.createToggleButtonStyler().setType(ButtonType.CENTER_PILL).style(tb2);
ToggleButton sampleButton4 = new ToggleButton("TG1"); sampleButton4.setToggleGroup(toolbarGroup); sampleButton4.setSelected(true); AquaFx.createToggleButtonStyler().setType(ButtonType.LEFT_PILL).style(sampleButton4); ToggleButton sampleButton5 = new ToggleButton("TG2"); sampleButton5.setToggleGroup(toolbarGroup); sampleButton5.setSelected(true); AquaFx.createToggleButtonStyler().setType(ButtonType.CENTER_PILL).style(sampleButton5); ToggleButton sampleButton6 = new ToggleButton("TG3"); sampleButton6.setToggleGroup(toolbarGroup); sampleButton6.setSelected(true); ToggleButton sampleButton2 = new ToggleButton("Toggle"); toolBar.getItems().addAll(tbBack, tbForward, share, combo, combo2, choice,separator, m,separator2, m2,separator3, colorTB, sampleButton, sampleButton2, seperateIt, sampleButton4, sampleButton5, sampleButton6);
ToggleButton restoreDefault = new ToggleButton(tr("Restore defaults")); restoreDefault.setOnAction(event -> { this.settingsManager.restoreDefaultRepositories();
uniformDesign.addIcon(iconLabel,icon); ToggleButton expandButton=new ToggleButton(); expandButton.selectedProperty().addListener((observable, oldValue, newValue) -> { if (newValue!=null && newValue){
AquaFx.createButtonStyler().setSizeVariant(ControlSizeVariant.REGULAR).style(b5); grid.add(b5, 1, 2); ToggleButton tb5 = new ToggleButton("ToggleButton"); AquaFx.createToggleButtonStyler().setSizeVariant(ControlSizeVariant.REGULAR).style(tb5); grid.add(tb5, 2, 2); AquaFx.createButtonStyler().setSizeVariant(ControlSizeVariant.SMALL).style(b6); grid.add(b6, 1, 3); ToggleButton tb6 = new ToggleButton("ToggleButton"); AquaFx.createToggleButtonStyler().setSizeVariant(ControlSizeVariant.SMALL).style(tb6); grid.add(tb6, 2, 3); AquaFx.createButtonStyler().setSizeVariant(ControlSizeVariant.MINI).style(b7); grid.add(b7, 1, 4); ToggleButton tb7 = new ToggleButton("ToggleButton"); AquaFx.createToggleButtonStyler().setSizeVariant(ControlSizeVariant.MINI).style(tb7); grid.add(tb7, 2, 4);
new ToggleButton("Button"), withState(new ToggleButton("Hover"), "hover"), withState(new ToggleButton("Armed"), "armed"), withState(new ToggleButton("Focused"), "focused"), withState(new ToggleButton("Focused & Hover"), "focused, hover"), withState(new ToggleButton("Focused & Armed"), "focused, armed"), withState(new ToggleButton("Disabled"), "disabled")); newSection("ToggleButton Selected:", withState(new ToggleButton("Button"), "selected"), withState(new ToggleButton("Hover"), "selected, hover"), withState(new ToggleButton("Armed"), "selected, armed"), withState(new ToggleButton("Focused"), "selected, focused"), withState(new ToggleButton("Focused & Hover"), "selected, focused, hover"), withState(new ToggleButton("Focused & Armed"), "selected, focused, armed"), withState(new ToggleButton("Disabled"), "selected, disabled")); newSection("CheckBox:", new CheckBox("CheckBox"),