javafx.scene.control.ToggleGroup Java Examples

The following examples show how to use javafx.scene.control.ToggleGroup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphEditorDemoController.java    From graph-editor with Eclipse Public License 1.0 7 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example #2
Source File: RadioButtons.java    From marathonv5 with Apache License 2.0 7 votes vote down vote up
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);
}
 
Example #3
Source File: SettingsActivity.java    From ApkToolPlus with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化选择项
 */
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);
}
 
Example #4
Source File: BurnBsqView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void initialize() {
    listener = viewPath -> {
        if (viewPath.size() != 4 || viewPath.indexOf(BurnBsqView.class) != 2)
            return;

        selectedViewClass = viewPath.tip();
        loadView(selectedViewClass);
    };

    toggleGroup = new ToggleGroup();
    final List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, BurnBsqView.class);
    assetFee = new MenuItem(navigation, toggleGroup, Res.get("dao.burnBsq.menuItem.assetFee"),
            AssetFeeView.class, baseNavPath);
    proofOfBurn = new MenuItem(navigation, toggleGroup, Res.get("dao.burnBsq.menuItem.proofOfBurn"),
            ProofOfBurnView.class, baseNavPath);

    leftVBox.getChildren().addAll(assetFee, proofOfBurn);
}
 
Example #5
Source File: EconomyView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void initialize() {
    listener = viewPath -> {
        if (viewPath.size() != 4 || viewPath.indexOf(EconomyView.class) != 2)
            return;

        selectedViewClass = viewPath.tip();
        loadView(selectedViewClass);
    };

    toggleGroup = new ToggleGroup();
    List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, EconomyView.class);
    dashboard = new MenuItem(navigation, toggleGroup, Res.get("shared.dashboard"), BsqDashboardView.class, baseNavPath);
    supply = new MenuItem(navigation, toggleGroup, Res.get("dao.factsAndFigures.menuItem.supply"), SupplyView.class, baseNavPath);
    transactions = new MenuItem(navigation, toggleGroup, Res.get("dao.factsAndFigures.menuItem.transactions"), BSQTransactionsView.class, baseNavPath);

    leftVBox.getChildren().addAll(dashboard, supply, transactions);

    if (!DevEnv.isDaoActivated()) {
        dashboard.setDisable(true);
        supply.setDisable(true);
        transactions.setDisable(true);
    }
}
 
Example #6
Source File: XPathRuleEditorController.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void initialiseVersionSelection() {
    ToggleGroup xpathVersionToggleGroup = new ToggleGroup();

    List<String> versionItems = new ArrayList<>();
    versionItems.add(XPathRuleQuery.XPATH_1_0);
    versionItems.add(XPathRuleQuery.XPATH_1_0_COMPATIBILITY);
    versionItems.add(XPathRuleQuery.XPATH_2_0);

    versionItems.forEach(v -> {
        RadioMenuItem item = new RadioMenuItem("XPath " + v);
        item.setUserData(v);
        item.setToggleGroup(xpathVersionToggleGroup);
        xpathVersionMenuButton.getItems().add(item);
    });

    xpathVersionUIProperty = DesignerUtil.mapToggleGroupToUserData(xpathVersionToggleGroup, DesignerUtil::defaultXPathVersion);

    xpathVersionProperty().setValue(XPathRuleQuery.XPATH_2_0);
}
 
Example #7
Source File: IconSwitch.java    From Enzo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: SessionContext.java    From jfxvnc with Apache License 2.0 6 votes vote down vote up
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())));
    }
  });
}
 
Example #9
Source File: BsqWalletView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void initialize() {
    listener = viewPath -> {
        if (viewPath.size() != 4 || viewPath.indexOf(BsqWalletView.class) != 2)
            return;

        selectedViewClass = viewPath.tip();
        loadView(selectedViewClass);
    };

    toggleGroup = new ToggleGroup();
    List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, BsqWalletView.class);
    send = new MenuItem(navigation, toggleGroup, Res.get("dao.wallet.menuItem.send"), BsqSendView.class, baseNavPath);
    receive = new MenuItem(navigation, toggleGroup, Res.get("dao.wallet.menuItem.receive"), BsqReceiveView.class, baseNavPath);
    transactions = new MenuItem(navigation, toggleGroup, Res.get("dao.wallet.menuItem.transactions"), BsqTxView.class, baseNavPath);
    leftVBox.getChildren().addAll(send, receive, transactions);

    if (!DevEnv.isDaoActivated()) {
        send.setDisable(true);
        transactions.setDisable(true);
    }
}
 
Example #10
Source File: TransactionTypeNodeProvider.java    From constellation with Apache License 2.0 6 votes vote down vote up
private VBox addFilter() {
    filterText.setPromptText("Filter transaction types");
    final ToggleGroup toggleGroup = new ToggleGroup();
    startsWithRb.setToggleGroup(toggleGroup);
    startsWithRb.setPadding(new Insets(0, 0, 0, 5));
    startsWithRb.setSelected(true);
    final RadioButton containsRadioButton = new RadioButton("Contains");
    containsRadioButton.setToggleGroup(toggleGroup);
    containsRadioButton.setPadding(new Insets(0, 0, 0, 5));

    toggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
        populateTree();
    });

    filterText.textProperty().addListener((observable, oldValue, newValue) -> {
        populateTree();
    });

    final HBox headerBox = new HBox(new Label("Filter: "), filterText, startsWithRb, containsRadioButton);
    headerBox.setAlignment(Pos.CENTER_LEFT);
    headerBox.setPadding(new Insets(5));

    final VBox box = new VBox(schemaLabel, headerBox, treeView);
    VBox.setVgrow(treeView, Priority.ALWAYS);
    return box;
}
 
Example #11
Source File: ListWidgetSelectorSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * {@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);
}
 
Example #12
Source File: SidebarToggleGroupBehavior.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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();
            }
        }
    }
}
 
Example #13
Source File: Demo.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@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"));
}
 
Example #14
Source File: NodePropertiesSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #15
Source File: OnOffSwitch.java    From Enzo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: NodePropertiesSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #17
Source File: SessionManager.java    From mokka7 with Eclipse Public License 1.0 6 votes vote down vote up
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())));
            }
        }
    });
}
 
Example #18
Source File: DataPlot.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** @param infos Info from {@link ScanInfoModel} */
private void updateScans(final List<ScanInfo> infos)
{
    final ToggleGroup group = new ToggleGroup();
    final List<MenuItem> names = new ArrayList<>(infos.size());

    final ScanDataReader safe_reader = reader;
    final long scan_id = safe_reader != null ? safe_reader.getScanId() : -1;
    for (ScanInfo info : infos)
    {
        final String label = MessageFormat.format(Messages.scan_name_id_fmt, info.getName(), info.getId());
        final RadioMenuItem item = new RadioMenuItem(label);
        item.setToggleGroup(group);
        if (scan_id == info.getId())
            item.setSelected(true);
        item.setOnAction(event -> selectScan(info.getId(), label));
        names.add(item);
    }
    Platform.runLater(() -> scan_selector.getItems().setAll(names));
}
 
Example #19
Source File: MonitorView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void initialize() {
    navigationListener = viewPath -> {
        if (viewPath.size() != 4 || viewPath.indexOf(MonitorView.class) != 2)
            return;

        selectedViewClass = viewPath.tip();
        loadView(selectedViewClass);
    };

    toggleGroup = new ToggleGroup();
    List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, MonitorView.class);
    daoState = new MenuItem(navigation, toggleGroup, Res.get("dao.monitor.daoState"),
            DaoStateMonitorView.class, baseNavPath);
    proposals = new MenuItem(navigation, toggleGroup, Res.get("dao.monitor.proposals"),
            ProposalStateMonitorView.class, baseNavPath);
    blindVotes = new MenuItem(navigation, toggleGroup, Res.get("dao.monitor.blindVotes"),
            BlindVoteStateMonitorView.class, baseNavPath);

    leftVBox.getChildren().addAll(daoState, proposals, blindVotes);
}
 
Example #20
Source File: GetNewSecret.java    From strongbox with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #21
Source File: ItemSelectionPane.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
public ItemSelectionPane(boolean toggleItems, ItemSelectionListener<T> itemListener) {
	super();

	this.itemListener = itemListener;
	this.toggleable = toggleItems;

	if (toggleable) {
		toggleGroup = new ToggleGroup();
	}

	subContainer.setPrefColumns(DEFAULT_COLUMNS);
	subContainer.setPadding(new Insets(0, 65, 65, 65));

	widthProperty().addListener((observable, oldValue, newValue) -> {
		final Insets padding = subContainer.getPadding();
		final int hgap = (int) subContainer.getHgap();
		final int columnCount = (newValue.intValue() - (int) (padding.getLeft() + padding.getRight()) + hgap)
				/ (ITEM_DIMS + hgap);

		if (columnCount <= MAX_COLUMNS) subContainer.setPrefColumns(columnCount);
	});

	setStyle("-fx-focus-color: transparent; -fx-faint-focus-color: transparent; -fx-background-color:transparent;");
	setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
	setHbarPolicy(ScrollBarPolicy.NEVER);
	setFitToHeight(true);
	setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
	setContent(subContainer);
}
 
Example #22
Source File: RadioChooserDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void initComponents()
{
	Pane outerPane = new VBox();
	JFXPanel jfxPanel = new JFXPanel();
	jfxPanel.setLayout(new BorderLayout());

	setTitle(LanguageBundle.getString("in_chooserSelectOne")); //$NON-NLS-1$
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

	Node titleLabel = new Text(chooser.getName());
	titleLabel.getStyleClass().add("chooserTitle");
	URL applicationCss = getClass().getResource("/pcgen/gui3/application.css");
	String asString = applicationCss.toExternalForm();
	outerPane.getStylesheets().add(asString);
	outerPane.getChildren().add(titleLabel);
	toggleGroup = new ToggleGroup();

	outerPane.getChildren().add(buildButtonPanel());

	this.getContentPane().setLayout(new GridLayout());
	this.getContentPane().add(jfxPanel, BorderLayout.CENTER);


	ButtonBar buttonBar = new OKCloseButtonBar(
			this::onOK,
			this::onCancel);
	outerPane.getChildren().add(buttonBar);
	Platform.runLater(() -> {
		Scene scene = new Scene(outerPane);
		jfxPanel.setScene(scene);
		SwingUtilities.invokeLater(this::pack);
	});
}
 
Example #23
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple4<Label, TextField, RadioButton, RadioButton> addTopLabelTextFieldRadioButtonRadioButton(GridPane gridPane,
                                                                                                            int rowIndex,
                                                                                                            ToggleGroup toggleGroup,
                                                                                                            String title,
                                                                                                            String textFieldTitle,
                                                                                                            String radioButtonTitle1,
                                                                                                            String radioButtonTitle2,
                                                                                                            double top) {
    TextField textField = new BisqTextField();
    textField.setPromptText(textFieldTitle);

    RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
    radioButton1.setToggleGroup(toggleGroup);
    radioButton1.setPadding(new Insets(6, 0, 0, 0));

    RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
    radioButton2.setToggleGroup(toggleGroup);
    radioButton2.setPadding(new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(textField, radioButton1, radioButton2);

    final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);

    return new Tuple4<>(labelVBoxTuple2.first, textField, radioButton1, radioButton2);
}
 
Example #24
Source File: JapanBankTransferForm.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addBankAccountTypeInput() // {{{
{
    // account currency
    gridRow++;

    TradeCurrency singleTradeCurrency = japanBankAccount.getSingleTradeCurrency();
    String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
    addCompactTopLabelTextField(gridPane, gridRow, Res.get("shared.currency"), nameAndCode, 20);

    // account type
    gridRow++;

    ToggleGroup toggleGroup = new ToggleGroup();
    Tuple3<Label, RadioButton, RadioButton> tuple3 =
        addTopLabelRadioButtonRadioButton(
            gridPane, gridRow, toggleGroup,
            JapanBankData.getString("account.type.select"),
            JapanBankData.getString("account.type.futsu"),
            JapanBankData.getString("account.type.touza"),
            0
        );

    toggleGroup.getToggles().get(0).setSelected(true);
    japanBankAccount.setBankAccountType(JapanBankData.getString("account.type.futsu.ja"));

    RadioButton futsu = tuple3.second;
    RadioButton touza = tuple3.third;

    toggleGroup.selectedToggleProperty().addListener
    (
        (ov, oldValue, newValue) ->
        {
            if (futsu.isSelected())
                japanBankAccount.setBankAccountType(JapanBankData.getString("account.type.futsu.ja"));
            if (touza.isSelected())
                japanBankAccount.setBankAccountType(JapanBankData.getString("account.type.touza.ja"));
        }
    );
}
 
Example #25
Source File: BondingView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void initialize() {
    listener = new Navigation.Listener() {
        @Override
        public void onNavigationRequested(ViewPath path) {
        }

        @Override
        public void onNavigationRequested(ViewPath viewPath, @Nullable Object data) {
            if (viewPath.size() != 4 || viewPath.indexOf(bisq.desktop.main.dao.bonding.BondingView.class) != 2)
                return;

            selectedViewClass = viewPath.tip();
            loadView(selectedViewClass, data);
        }
    };

    toggleGroup = new ToggleGroup();
    final List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, bisq.desktop.main.dao.bonding.BondingView.class);
    dashboard = new MenuItem(navigation, toggleGroup, Res.get("shared.dashboard"),
            BondingDashboardView.class, baseNavPath);
    bondedRoles = new MenuItem(navigation, toggleGroup, Res.get("dao.bond.menuItem.bondedRoles"),
            RolesView.class, baseNavPath);
    reputation = new MenuItem(navigation, toggleGroup, Res.get("dao.bond.menuItem.reputation"),
            MyReputationView.class, baseNavPath);
    bonds = new MenuItem(navigation, toggleGroup, Res.get("dao.bond.menuItem.bonds"),
            BondsView.class, baseNavPath);

    leftVBox.getChildren().addAll(dashboard, bondedRoles, reputation, bonds);
}
 
Example #26
Source File: RichTextDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ToggleButton createToggleButton(ToggleGroup grp, String styleClass, Runnable action, String toolTip) {
    ToggleButton button = new ToggleButton();
    button.setToggleGroup(grp);
    button.getStyleClass().add(styleClass);
    button.setOnAction(evt -> {
        action.run();
        area.requestFocus();
    });
    button.setPrefWidth(25);
    button.setPrefHeight(25);
    if (toolTip != null) {
        button.setTooltip(new Tooltip(toolTip));
    }
    return button;
}
 
Example #27
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public RadioButton getRadioButton(String text, VBox vbox, ToggleGroup group)
{
  RadioButton button = new RadioButton(text);
  vbox.getChildren().add(button);
  button.setToggleGroup(group);
  button.setDisable(true);
  return button;
}
 
Example #28
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public RadioButton getRadioButton(String text, HBox hbox, ToggleGroup group)
{
  RadioButton button = new RadioButton(text);
  hbox.getChildren().add(button);
  button.setToggleGroup(group);
  button.setDisable(true);
  return button;
}
 
Example #29
Source File: FontManagerType1.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
private RadioMenuItem setMenuItem (Menu menu, ToggleGroup toggleGroup, String itemName,
    String selectedItemName, boolean disable)
{
  RadioMenuItem item = new RadioMenuItem (itemName);
  item.setToggleGroup (toggleGroup);
  menu.getItems ().add (item);
  if (itemName.equals (selectedItemName))
    item.setSelected (true);
  item.setDisable (disable);
  item.setUserData (itemName);
  item.setOnAction (e -> selectFont ());
  return item;
}
 
Example #30
Source File: AttributeNodeProvider.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void setContent(final Tab tab) {
    GraphManager.getDefault().addGraphManagerListener(this);
    newActiveGraph(GraphManager.getDefault().getActiveGraph());

    final TextField filterText = new TextField();
    filterText.setPromptText("Filter attribute names");

    final ToggleGroup tg = new ToggleGroup();
    final RadioButton startsWithRb = new RadioButton("Starts with");
    startsWithRb.setToggleGroup(tg);
    startsWithRb.setPadding(new Insets(0, 0, 0, 5));
    startsWithRb.setSelected(true);
    final RadioButton containsRb = new RadioButton("Contains");
    containsRb.setToggleGroup(tg);
    containsRb.setPadding(new Insets(0, 0, 0, 5));

    tg.selectedToggleProperty().addListener((ov, oldValue, newValue) -> {
        filter(table, filterText.getText(), startsWithRb.isSelected());
    });

    filterText.textProperty().addListener((ov, oldValue, newValue) -> {
        filter(table, newValue, startsWithRb.isSelected());
    });

    final HBox headerBox = new HBox(new Label("Filter: "), filterText, startsWithRb, containsRb);
    headerBox.setAlignment(Pos.CENTER_LEFT);
    headerBox.setPadding(new Insets(5));

    final VBox box = new VBox(schemaLabel, headerBox, table);
    VBox.setVgrow(table, Priority.ALWAYS);

    Platform.runLater(() -> {
        tab.setContent(box);
    });
}