private RadioButton createRadioButton(final Node rect, String name, final boolean toFront, ToggleGroup tg) { final RadioButton radioButton = new RadioButton(name); radioButton.setToggleGroup(tg); radioButton.selectedProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (radioButton.isSelected()) { if (toFront) { rect.toFront(); } else { rect.toBack(); } } } }); return radioButton; }
public RadioButtons() { super(400,100); ToggleGroup tg = new ToggleGroup(); VBox vbox = new VBox(); vbox.setSpacing(5); RadioButton rb1 = new RadioButton("Hello"); rb1.setToggleGroup(tg); RadioButton rb2 = new RadioButton("Bye"); rb2.setToggleGroup(tg); rb2.setSelected(true); RadioButton rb3 = new RadioButton("Disabled"); rb3.setToggleGroup(tg); rb3.setSelected(false); rb3.setDisable(true); vbox.getChildren().add(rb1); vbox.getChildren().add(rb2); vbox.getChildren().add(rb3); getChildren().add(vbox); }
/** * Create a radio button for each String in the list, add them to the container, and bind the selected value to the * String property * * @param container Container to put radio buttons in * @param radioBtns List of Strings, one for each radio button * @param modelProperty Property to bind selected radio button's value to */ public static ToggleGroupValue createButtonGroup(Pane container, List<String> radioBtns, StringProperty modelProperty) { // Create new ToggleGroup and ToggleGroupValue for the radio buttons ToggleGroupValue groupValue = new ToggleGroupValue(); ToggleGroup btnsGroup = new ToggleGroup(); // Create a radio button for each option for (String s : radioBtns) { // Create radio button for this option RadioButton radioBtn = new RadioButton(s); radioBtn.setUserData(s); radioBtn.setToggleGroup(btnsGroup); // Add to RadioButton to the container pane and the ToggleGroupValue container.getChildren().add(radioBtn); groupValue.add(radioBtn, radioBtn.getUserData()); } // Bind toggle group value to model modelProperty.bindBidirectional(groupValue.valueProperty()); // Select first option groupValue.setValue(radioBtns.get(0)); return groupValue; }
public void bind(final ToggleGroup toggleGroup, final String propertyName) { try { String value = props.getProperty(propertyName); if (value != null) { int selectedToggleIndex = Integer.parseInt(value); toggleGroup.selectToggle(toggleGroup.getToggles().get(selectedToggleIndex)); } } catch (Exception ignored) { } toggleGroup.selectedToggleProperty().addListener(new InvalidationListener() { @Override public void invalidated(Observable o) { if (toggleGroup.getSelectedToggle() == null) { props.remove(propertyName); } else { props.setProperty(propertyName, Integer.toString(toggleGroup.getToggles().indexOf(toggleGroup.getSelectedToggle()))); } } }); }
private void updateMenuItems() { ToggleGroup group = new ToggleGroup(); List<MenuItem> items = new ArrayList<>(); for (Calendar calendar : getSkinnable().getCalendars()) { RadioMenuItem item = new RadioMenuItem(calendar.getName()); Rectangle icon = new Rectangle(10, 10); icon.setArcHeight(2); icon.setArcWidth(2); icon.getStyleClass().add(calendar.getStyle() + "-icon"); //$NON-NLS-1$ item.setGraphic(icon); item.setDisable(calendar.isReadOnly()); item.setOnAction(evt -> getSkinnable().setCalendar(calendar)); group.getToggles().add(item); items.add(item); if (calendar.equals(getSkinnable().getCalendar())) { item.setSelected(true); } } button.getItems().setAll(items); }
private SecretValue getSecretValue(ToggleGroup valueSource, String value, String generated, File file) { Toggle current = valueSource.getSelectedToggle(); String secretString; if (current.getUserData().equals("value")) { secretString = value; } else if (current.getUserData().equals("generated")) { Integer numBytesToGenerate = Integer.valueOf(generated); // TODO: store as plain bytes? byte[] random = Singleton.randomGenerator.generateRandom(numBytesToGenerate); secretString = Base64.encodeAsString(random); } else { String path = null; try { path = file.getCanonicalPath(); return SecretValueConverter.inferEncoding(Files.readAllBytes(Paths.get(path)), SecretType.OPAQUE); } catch (IOException e) { throw new RuntimeException("Failed to read secret from file"); } } return new SecretValue(secretString, SecretType.OPAQUE); }
private void initMenu() { recentSupport = new RecentFileMenuSupport(openRecentMenu) { @Override public List<String> load() { return Arrays.asList(Config.getProperty(ConfigKey.RECENT_LOCATIONS, "").split(",")); } @Override public void save(List<String> s) { Config.setProperty(ConfigKey.RECENT_LOCATIONS, String.join(", ", s)); } }; recentSupport.setOnAction(this::openFile); ToggleGroup group = new ToggleGroup(); for (SkinStyle style : Context.SKIN.getSkinList()) { RadioMenuItem item = new RadioMenuItem(style.getName()); item.setToggleGroup(group); item.setOnAction(e -> Context.SKIN.changeSkin(style)); if (Context.SKIN.currentSkin() == style) { item.setSelected(true); } skinMenu.getItems().add(item); } }
/** * 初始化选择项 */ private void initItems(){ // 左边的选择项 ObservableList<Node> items = boxItems.getChildren(); ToggleGroup group = new ToggleGroup(); // 关联group和index for(int index=0; index<items.size(); ++index){ ToggleButton item = (ToggleButton) items.get(index); item.setToggleGroup(group); item.setUserData(index); } // 切换监听 group.selectedToggleProperty().addListener((observable, oldValue, newValue) ->{ if(newValue != null){ Integer itemIndex = (Integer) newValue.getUserData(); showSettingContent(itemIndex); }else{ group.selectToggle(oldValue); } }); // 默认选择第一个 group.getToggles().get(0).setSelected(true); }
/** * Data selector between VoogaBoolean and VoogaNumber. * @return */ private HBox makeDataSelector () { ToggleGroup group = new ToggleGroup(); RadioButton number = new RadioButton("Number"); number.setToggleGroup(group); number.setSelected(true); RadioButton bool = new RadioButton("Boolean"); bool.setToggleGroup(group); number.selectedProperty().addListener( (obs, old, newVal) -> { container.getChildren().remove(buttons); if (newVal) { container.getChildren().add(numberSelector); container.getChildren().remove(boolSelector); chosenData = VOOGA_NUMBER; } else { container.getChildren().remove(numberSelector); container.getChildren().add(boolSelector); chosenData = VOOGA_BOOLEAN; } container.getChildren().add(buttons); }); return GUIUtils.makeRow(number, bool); }
public SessionConflictDialog( Session scheduled, Session proposed, SessionVisuals sessionVisuals ){ this.rootNode.getStyleClass().add("session-conflict-dialog"); this.sessionVisuals = sessionVisuals; setTitle(new Label(OTNBundle.getString("OTN.CONFLICT.SCHEDULE_CONFLICT"))); RadioButton rbScheduled = new RadioButton(OTNBundle.getString("OTN.CONFLICT.CURRENTLY_SCHEDULED")); RadioButton rbProposed = new RadioButton(OTNBundle.getString("OTN.CONFLICT.PROPOSED")); ToggleGroup group = new ToggleGroup(); group.getToggles().addAll(rbScheduled, rbProposed); group.selectToggle(rbScheduled); final VBox vBox = new VBox( new Label(OTNBundle.getString("OTN.CONFLICT.QUESTION")), sessionPane(scheduled, rbScheduled), sessionPane(proposed, rbProposed)); vBox.getStyleClass().add("content"); setContent(vBox); getButtons().addAll( createButton(OTNBundle.getString("OTN.BUTTON.CANCEL"), () -> null), createButton(OTNBundle.getString("OTN.BUTTON.SCHEDULE"), () -> rbProposed.isSelected() ? proposed: scheduled)); }
@Override public Node impl_drawNode() { try { vb = FXMLLoader.load(resource); } catch (Exception e) { System.out.println("message: " + e.getMessage()); reportGetterFailure("exception thrown."); } LinkedList<ToggleGroup> toggleGroups = new LinkedList<ToggleGroup>(); for(Node child: vb.getChildren()) { toggleGroups.add(((RadioButton) child).getToggleGroup()); } for(int i = 0; i < toggleGroups.size() - 2; i ++) { if(!toggleGroups.get(i).equals(toggleGroups.get(i + 1))) { reportGetterFailure("failed."); return redRectangle; } } return retRec; }
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; }
private <T extends Enum> VBox enumChoiceBox(final Class<T> enumClass, final Enum currentValue) { final T[] values = enumClass.getEnumConstants(); final List<RadioButton> buttons = new ArrayList<>(); final ToggleGroup toggleGroup = new ToggleGroup(); for (T value : values) { final RadioButton button = new RadioButton(value.toString()); button.setToggleGroup(toggleGroup); button.setSelected(value.equals(currentValue)); buttons.add(button); } final VBox result = new VBox(); result.setSpacing(10.0); result.getChildren().addAll(buttons); return result; }
private HBox criaPainelSuperior() { HBox hbTopo = new HBox(10); hbTopo.setSpacing(10); hbTopo.setAlignment(Pos.CENTER); Transicoes[] transicoes = Transicoes.values(); // grupo para todas as transições botoesTransicao = new ToggleGroup(); Stream.of(transicoes).map(t -> { ToggleButton tb = new ToggleButton(t.name()); tb.setUserData(t); tb.setToggleGroup(botoesTransicao); return tb; }).forEach(hbTopo.getChildren()::add); botoesTransicao.getToggles().get(0).setSelected(true); return hbTopo; }
public ToggleButton getActionToggleButton(GUIActions actionType, boolean hideActionText, ToggleGroup group) { Action action = getAction(actionType); ToggleButton button = ActionUtils.createToggleButton(action, hideActionText ? ActionTextBehavior.HIDE : ActionTextBehavior.SHOW); if (hideActionText && action.getText() != null) { Tooltip.install(button, new Tooltip(action.getText())); // button.setTooltip(new Tooltip(action.getText())); //// button.setText(null); } // Internally, ControlsFX duplicates graphics (or gives up) because Nodes can't appear multiple times the scene graph // Consequently, we need to bind changes to the text fill here so that they filter through if (button.getGraphic() instanceof Glyph) { ((Glyph)button.getGraphic()).textFillProperty().bind(((Glyph)action.getGraphic()).textFillProperty()); } if (group != null) button.setToggleGroup(group); return button; }
private LinkedList<RadioButton> setupToggle(ToggleGroup group) { // Use Dijkstra as default RadioButton rbD = new RadioButton("Dijkstra"); rbD.setUserData("Dijkstra"); rbD.setSelected(true); RadioButton rbA = new RadioButton("A*"); rbA.setUserData("A*"); RadioButton rbB = new RadioButton("BFS"); rbB.setUserData("BFS"); rbB.setToggleGroup(group); rbD.setToggleGroup(group); rbA.setToggleGroup(group); return new LinkedList<RadioButton>(Arrays.asList(rbB, rbD, rbA)); }
public ModeSelectorViewJfx() { hBox = new HBox(25); hBox.setMaxHeight(40); hBox.setAlignment(Pos.CENTER_LEFT); Label modeLabel = new Label("Mode:"); hostButton = new RadioButton("Host"); guestButton = new RadioButton("Guest"); ToggleGroup toggleGroup = new ToggleGroup(); hostButton.setToggleGroup(toggleGroup); guestButton.setToggleGroup(toggleGroup); HBox.setMargin(modeLabel, new Insets(0, 30, 0, 0)); hBox.getChildren().addAll(modeLabel, hostButton, guestButton); }
/** * Initializes the list of zoom options. */ private void initializeZoomOptions() { final ToggleGroup toggleGroup = new ToggleGroup(); for (int i = 1; i <= 5; i++) { final RadioMenuItem zoomOption = new RadioMenuItem(); final double zoomFactor = i; zoomOption.setText(i + "00%"); zoomOption.setOnAction(event -> setZoomFactor(zoomFactor)); toggleGroup.getToggles().add(zoomOption); zoomOptions.getItems().add(zoomOption); if (i == 1) { zoomOption.setSelected(true); } } }
@Override public void initialize(URL location, ResourceBundle resources) { importer = new WebImporter(); importMode = HtmlImportMode.ORIGINAL; ObservableList<Node> nodes = modesBox.getChildren(); nodes.clear(); final ToggleGroup modesGroup = new ToggleGroup(); for (HtmlImportMode value : HtmlImportMode.values()) { RadioButton radio = new RadioButton(resources.getString(value.getName())); if (value == importMode) radio.setSelected(true); radio.setOnAction(e -> onModeChanged(value)); radio.setToggleGroup(modesGroup); nodes.add(radio); } pagePreview.getEngine().loadContent(resources.getString("preview"), "text/html"); }
public final ObjectProperty<ToggleGroup> toggleGroupProperty() { if (null == toggleGroup) { toggleGroup = new ObjectPropertyBase<ToggleGroup>() { private ToggleGroup oldToggleGroup; @Override protected void invalidated() { final ToggleGroup toggleGroup = get(); if (null != toggleGroup && !toggleGroup.getToggles().contains(IconSwitch.this)) { if (oldToggleGroup != null) { oldToggleGroup.getToggles().remove(IconSwitch.this); } toggleGroup.getToggles().add(IconSwitch.this); } else if (null == toggleGroup) { oldToggleGroup.getToggles().remove(IconSwitch.this); } oldToggleGroup = toggleGroup; } @Override public Object getBean() { return IconSwitch.this; } @Override public String getName() { return "toggleGroup"; } }; } return toggleGroup; }
@Override public void init() { onOffSwitch = new OnOffSwitch(); ToggleGroup iconSwitchToggleGroup = new ToggleGroup(); iconSwitchSymbol = new IconSwitch(); iconSwitchSymbol.setToggleGroup(iconSwitchToggleGroup); iconSwitchSymbol.setSelected(true); iconSwitchSymbol.setSymbolType(SymbolType.POWER); iconSwitchSymbol.setSymbolColor(Color.web("#34495e")); iconSwitchText = new IconSwitch(); iconSwitchText.setToggleGroup(iconSwitchToggleGroup); iconSwitchText.setText("A"); iconSwitchText.setSymbolColor(Color.web("#34495e")); iconSwitchSymbol1 = new IconSwitch(); iconSwitchSymbol1.setSymbolType(SymbolType.ALARM); iconSwitchSymbol1.setSymbolColor(Color.web("#34495e")); onOffSwitch.setOnSelect(switchEvent -> System.out.println("OnOff Switch switched on")); iconSwitchSymbol.setOnSelect(switchEvent -> System.out.println("Icon Switch Symbol switched on")); iconSwitchText.setOnSelect(switchEvent -> System.out.println("Icon Switch Text switched on")); iconSwitchSymbol1.setOnSelect(switchEvent -> System.out.println("Icon Switch Symbol 1 switched on")); }
public final ObjectProperty<ToggleGroup> toggleGroupProperty() { if (null == toggleGroup) { toggleGroup = new ObjectPropertyBase<ToggleGroup>() { private ToggleGroup oldToggleGroup; @Override protected void invalidated() { final ToggleGroup toggleGroup = get(); if (null != toggleGroup && !toggleGroup.getToggles().contains(OnOffSwitch.this)) { if (oldToggleGroup != null) { oldToggleGroup.getToggles().remove(OnOffSwitch.this); } toggleGroup.getToggles().add(OnOffSwitch.this); } else if (null == toggleGroup) { oldToggleGroup.getToggles().remove(OnOffSwitch.this); } oldToggleGroup = toggleGroup; } @Override public Object getBean() { return OnOffSwitch.this; } @Override public String getName() { return "toggleGroup"; } }; } return toggleGroup; }
/** * Constructor for a Pane with Toogle Buttons. * @param width width of the parent */ public ContextSortingPane(final double width) { final ToggleGroup toggleGroup = new ToggleGroup(); final ToggleButton locationBtn = new ToggleButton("Location"); locationBtn.setToggleGroup(toggleGroup); locationBtn.setMaxWidth(Double.MAX_VALUE); locationBtn.setPrefWidth(width / 2); final ToggleButton functionBtn = new ToggleButton("Function"); functionBtn.setToggleGroup(toggleGroup); functionBtn.setMaxWidth(Double.MAX_VALUE); functionBtn.setPrefWidth(width / 2); //CHECKSTYLE.OFF: MultipleStringLiterals locationBtn.getStyleClass().addAll("visible-lg", "visible-md", "visible-sm", "visible-xs"); functionBtn.getStyleClass().addAll("visible-lg", "visible-md", "visible-sm", "visible-xs"); //CHECKSTYLE.ON: MultipleStringLiterals this.setToggleGroup(toggleGroup); this.getButtons().addAll(locationBtn, functionBtn); this.setMaxWidth(Double.MAX_VALUE); //this.setPrefWidth(width); this.setPadding(new Insets(Constants.INSETS, Constants.INSETS, Constants.INSETS, Constants.INSETS)); }
@Override public void bindToCuteElement(CuteElement editableCopyOfCE, CuteElement origCE) { relationChecker = (RelationToNumberChecker) editableCopyOfCE; origRelationChecker = (RelationToNumberChecker) origCE; BooleanNumberOperator operator = relationChecker.getOperator(); setOperatorHintBasedOnOperator(operator); ToggleButton t = mapWithButtons.get(operator.name()); t.setSelected(true); ToggleGroup tg = segmentedButton.getToggleGroup(); tg.selectedToggleProperty().addListener(toggleListener); numberTextField.numberProperty().bindBidirectional(relationChecker.compareNumberProperty()); // Let's set descriptions for operator popovers. for (ToggleButton button: segmentedButton.getButtons()) { BooleanNumberOperator ButtonOperator = BooleanNumberOperator.valueOf(button.getText()); String description = relationChecker.getFullDescriptionOfOperator(ButtonOperator); // Create popover (kind of tooltip) with description for each button. Label popOverLabel = new Label(description); popOverLabel.setPadding(new Insets(5,5,5,5)); GUIUtil.setPopOverTooltipToNode(button, popOverLabel, -7); } }
private ContextMenu buildRemoveButtonContextMenu() { final ContextMenu removeOptionsMenu = new ContextMenu(); final List<RadioMenuItem> removeOptionMenuItems = Arrays.asList(new RadioMenuItem[]{ new RadioMenuItem("Remove"), new RadioMenuItem("Remove and delete .torrent"), new RadioMenuItem("Remove and delete .torrent + Data"), new RadioMenuItem("Remove and delete Data")}); final ToggleGroup removeOptionsToggle = new ToggleGroup(); removeOptionMenuItems.forEach(i -> i.setToggleGroup(removeOptionsToggle)); removeOptionMenuItems.get(0).setSelected(true); removeOptionsMenu.getItems().addAll(removeOptionMenuItems); removeOptionsMenu.getItems().addAll(new SeparatorMenuItem(), new CheckMenuItem("Move to trash if possible")); return removeOptionsMenu; }
public void bind(final ToggleGroup toggleGroup, final String propertyName) { try { String value = props.getProperty(propertyName); if (value != null) { int selectedToggleIndex = Integer.parseInt(value); toggleGroup.selectToggle(toggleGroup.getToggles().get(selectedToggleIndex)); } } catch (Exception ignored) { } toggleGroup.selectedToggleProperty().addListener(o -> { if (toggleGroup.getSelectedToggle() == null) { props.remove(propertyName); } else { props.setProperty(propertyName, Integer.toString(toggleGroup.getToggles().indexOf(toggleGroup.getSelectedToggle()))); } }); }
@Override public void initialize() { listener = viewPath -> { if (viewPath.size() != 4 || viewPath.indexOf(VotingView.class) != 2) return; selectedViewClass = viewPath.tip(); loadView(selectedViewClass); }; ToggleGroup toggleGroup = new ToggleGroup(); dashboard = new MenuItem(navigation, toggleGroup, Res.get("shared.dashboard"), VotingDashboardView.class, AwesomeIcon.DASHBOARD); vote = new MenuItem(navigation, toggleGroup, Res.get("share.vote"), VoteView.class, AwesomeIcon.EDIT); history = new MenuItem(navigation, toggleGroup, Res.get("share.history"), VotingHistoryView.class, AwesomeIcon.TABLE); leftVBox.getChildren().addAll(dashboard, vote, history); }
@Override public void initialize() { listener = viewPath -> { if (viewPath.size() != 4 || viewPath.indexOf(CompensationView.class) != 2) return; selectedViewClass = viewPath.tip(); loadView(selectedViewClass); }; ToggleGroup toggleGroup = new ToggleGroup(); create = new MenuItem(navigation, toggleGroup, Res.get("dao.compensation.menuItem.createRequest"), CreateCompensationRequestView.class, AwesomeIcon.EDIT); active = new MenuItem(navigation, toggleGroup, Res.get("dao.compensation.menuItem.activeRequests"), ActiveCompensationRequestView.class, AwesomeIcon.ARROW_RIGHT); past = new MenuItem(navigation, toggleGroup, Res.get("dao.compensation.menuItem.pastRequests"), PastCompensationRequestView.class, AwesomeIcon.LIST); leftVBox.getChildren().addAll(create, active, past); }
@Override public void initialize() { listener = viewPath -> { if (viewPath.size() != 4 || viewPath.indexOf(BsqWalletView.class) != 2) return; selectedViewClass = viewPath.tip(); loadView(selectedViewClass); }; ToggleGroup toggleGroup = new ToggleGroup(); dashboard = new MenuItem(navigation, toggleGroup, Res.get("shared.dashboard"), BsqDashboardView.class, AwesomeIcon.DASHBOARD); send = new MenuItem(navigation, toggleGroup, Res.get("dao.wallet.menuItem.send"), BsqSendView.class, AwesomeIcon.SIGNOUT); receive = new MenuItem(navigation, toggleGroup, Res.get("dao.wallet.menuItem.receive"), BsqReceiveView.class, AwesomeIcon.SIGNIN); transactions = new MenuItem(navigation, toggleGroup, Res.get("dao.wallet.menuItem.transactions"), BsqTxView.class, AwesomeIcon.TABLE); leftVBox.getChildren().addAll(dashboard, send, receive, transactions); // TODO just until DAO is enabled if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq()) { dashboard.setDisable(true); send.setDisable(true); transactions.setDisable(true); } }
@Override public void initialize() { listener = viewPath -> { if (viewPath.size() != 4 || viewPath.indexOf(AccountSettingsView.class) != 2) return; selectedViewClass = viewPath.tip(); loadView(selectedViewClass); }; ToggleGroup toggleGroup = new ToggleGroup(); paymentAccount = new MenuItem(navigation, toggleGroup, Res.get("account.menu.paymentAccount"), FiatAccountsView.class, AwesomeIcon.MONEY); altCoinsAccountView = new MenuItem(navigation, toggleGroup, Res.get("account.menu.altCoinsAccountView"), AltCoinAccountsView.class, AwesomeIcon.LINK); arbitratorSelection = new MenuItem(navigation, toggleGroup, Res.get("account.menu.arbitratorSelection"), ArbitratorSelectionView.class, AwesomeIcon.USER_MD); password = new MenuItem(navigation, toggleGroup, Res.get("account.menu.password"), PasswordView.class, AwesomeIcon.UNLOCK_ALT); seedWords = new MenuItem(navigation, toggleGroup, Res.get("account.menu.seedWords"), SeedWordsView.class, AwesomeIcon.KEY); backup = new MenuItem(navigation, toggleGroup, Res.get("account.menu.backup"), BackupView.class, AwesomeIcon.CLOUD_DOWNLOAD); leftVBox.getChildren().addAll(paymentAccount, altCoinsAccountView, arbitratorSelection, password, seedWords, backup); }
public MessageTypeDialog() { super(null, "Choose message type", false, DialogStyle.NATIVE); setMasthead("Choose message type"); group = new ToggleGroup(); RadioButton textButton = new RadioButton("Text"); textButton.setUserData(new JmsTextMessage()); textButton.setToggleGroup(group); textButton.setSelected(true); RadioButton bytesButton = new RadioButton("Bytes"); bytesButton.setUserData(new JmsBytesMessage()); bytesButton.setToggleGroup(group); HBox hbox = new HBox(5); hbox.getChildren().add(textButton); hbox.getChildren().add(bytesButton); setContent(hbox); Action action = new JmsMessageAction(); action.disabledProperty().bind(group.selectedToggleProperty().isNull()); ButtonBar.setType(action, ButtonBar.ButtonType.OK_DONE); getActions().addAll(action, Dialog.Actions.CANCEL); }
@Override public void start(Stage stage) throws Exception { this.stage = stage; configureScene(); configureStage(); ToggleGroup tg = new ToggleGroup(); final ToggleButton tb1 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(true)).text("Not present in family").build(); tb1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if(tb1.selectedProperty().get()){ System.out.println("Selected"); }else{ System.out.println("Deselected"); } } }); ToggleButton tb2 = ToggleButtonBuilder.create().styleClass("graphic-toggle-button").toggleGroup(tg).graphic(buildDiseaseStatusIcon(false)).text("Not present in family").build(); // Logic starts HBox hb = HBoxBuilder.create().spacing(15).build(); hb.getChildren().addAll(tb1,tb2); root.getChildren().add(hb); //ScenicView.show(scene); }
@Override public void start(Stage stage) throws Exception { this.stage = stage; configureScene(); configureStage(); NonDeselectableToggleButton tb1 = new NonDeselectableToggleButton( "Hello World"); tb1.getToggleButton().setPrefWidth(200); NonDeselectableToggleButton tb2 = new NonDeselectableToggleButton( "Super World"); ToggleGroup gp = new ToggleGroup(); tb1.setToggleGroup(gp); tb2.setToggleGroup(gp); VBox vb = new VBox(); vb.setSpacing(10); vb.getChildren().addAll(tb1, tb2); root.getChildren().add(vb); }
@Override public void start(Stage stage) throws Exception { this.stage = stage; configureScene(); configureStage(); // Logic starts VBox vb = new VBox(); vb.setSpacing(10); ToggleGroup tg = new ToggleGroup(); vb.getChildren().addAll(RadioButtonBuilder.create().text("First").styleClass("radio-checkbox").toggleGroup(tg).build(), RadioButtonBuilder.create().text("Second").styleClass("radio-checkbox").toggleGroup(tg).build(), RadioButtonBuilder.create().text("Third").styleClass("radio-checkbox").toggleGroup(tg).build()); root.getChildren().add(vb); }