javafx.scene.control.Toggle Java Examples
The following examples show how to use
javafx.scene.control.Toggle.
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: ActionsDialog.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** @return {@link OpenDisplayActionInfo} from sub pane */ private OpenDisplayActionInfo getOpenDisplayAction() { Target target = Target.REPLACE; List<Toggle> modes = open_display_targets.getToggles(); for (int i=0; i<modes.size(); ++i) if (modes.get(i).isSelected()) { target = Target.values()[i]; break; } return new OpenDisplayActionInfo(open_display_description.getText(), open_display_path.getText().trim(), open_display_macros.getMacros(), target, open_display_pane.getText().trim()); }
Example #2
Source File: MainStage.java From oim-fx with MIT License | 6 votes |
void initEvent() { // group.selectedToggleProperty().addListener((ObservableValue<? extends // Toggle> observable, Toggle oldValue, Toggle selectedToggle) -> { // // if (selectedToggle instanceof ImageToggleButton) { // Object ud = selectedToggle.getUserData(); // if (ud instanceof Node) { // setSelectedNode((Node) ud); // } // } else if (oldValue != null) { // group.selectToggle(oldValue); // } // }); group.selectedToggleProperty().addListener((ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) -> { if (newValue == null) { group.selectToggle(oldValue); } // System.out.println("group"); }); }
Example #3
Source File: SidebarToggleGroupBehavior.java From phoenicis with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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 #4
Source File: RadioChooserDialog.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private void onOK(final ActionEvent ignored) { Toggle selectedToggle = toggleGroup.getSelectedToggle(); Logging.debugPrint("selected toggle is " + selectedToggle); if (selectedToggle != null) { Integer whichItemId = (Integer)selectedToggle.getUserData(); InfoFacade selectedItem = chooser.getAvailableList().getElementAt(whichItemId); chooser.addSelected(selectedItem); } if (chooser.isRequireCompleteSelection() && (chooser.getRemainingSelections().get() > 0)) { Dialog<ButtonType> alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(chooser.getName()); alert.setContentText(LanguageBundle.getFormattedString("in_chooserRequireComplete", chooser.getRemainingSelections().get())); alert.showAndWait(); return; } chooser.commit(); committed = true; this.dispose(); }
Example #5
Source File: RadioChooserDialog.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private void onOK(final ActionEvent ignored) { Toggle selectedToggle = toggleGroup.getSelectedToggle(); Logging.debugPrint("selected toggle is " + selectedToggle); if (selectedToggle != null) { Integer whichItemId = (Integer)selectedToggle.getUserData(); InfoFacade selectedItem = chooser.getAvailableList().getElementAt(whichItemId); chooser.addSelected(selectedItem); } if (chooser.isRequireCompleteSelection() && (chooser.getRemainingSelections().get() > 0)) { Dialog<ButtonType> alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(chooser.getName()); alert.setContentText(LanguageBundle.getFormattedString("in_chooserRequireComplete", chooser.getRemainingSelections().get())); alert.showAndWait(); return; } chooser.commit(); committed = true; this.dispose(); }
Example #6
Source File: MessagesPage.java From helloiot with GNU General Public License v3.0 | 6 votes |
private void printPayload(Toggle t) { Node n = getBottom(); if (n == null && t != null) { setBottom(payloadcontainer); } else if (n!= null && t == null) { setBottom(null); } if (currentmessage == null || t == null) { topic.setText(null); topic.setVisible(false); payload.setText(null); payload.setVisible(false); } else { topic.setText(currentmessage.getTopic()); topic.setVisible(true); StringFormat format = (StringFormat) t.getUserData(); String txt = format.format(format.value(currentmessage.getMessage())); payload.setText(txt); payload.setVisible(true); } }
Example #7
Source File: TextEditerController.java From MyBox with Apache License 2.0 | 6 votes |
@Override protected void initLineBreakTab() { try { super.initLineBreakTab(); lineBreakGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { checkLineBreakGroup(); } }); } catch (Exception e) { logger.error(e.toString()); } }
Example #8
Source File: SettingsController.java From MyBox with Apache License 2.0 | 6 votes |
protected void checkControlsColor(Toggle s) { try { if (isSettingValues) { return; } if (s == null || redRadio.equals(s)) { ControlStyle.setConfigColorStyle("default"); } else if (pinkRadio.equals(s)) { ControlStyle.setConfigColorStyle("pink"); } else if (lightBlueRadio.equals(s)) { ControlStyle.setConfigColorStyle("lightblue"); } else if (blueRadio.equals(s)) { ControlStyle.setConfigColorStyle("blue"); } else if (orangeRadio.equals(s)) { ControlStyle.setConfigColorStyle("orange"); } else { return; } refresh(); } catch (Exception e) { logger.error(e.toString()); } }
Example #9
Source File: ImageManufacturePaneController.java From MyBox with Apache License 2.0 | 6 votes |
public void initScopeBox() { try { typeGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue ov, Toggle oldValue, Toggle newValue) { if (isSettingValues) { return; } checkScopeType(true); } }); } catch (Exception e) { logger.error(e.toString()); } }
Example #10
Source File: ChromaticityBaseController.java From MyBox with Apache License 2.0 | 6 votes |
public void initOptions() { if (algorithmGroup != null) { algorithmGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { checkAlgorithm(); } }); checkAlgorithm(); } if (scaleInput != null) { scaleInput.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { checkScale(); } }); int p = AppVariables.getUserConfigInt("MatrixDecimalScale", 8); scaleInput.setText(p + ""); } }
Example #11
Source File: ImageManufactureBatchController.java From MyBox with Apache License 2.0 | 6 votes |
@Override public void initTargetSection() { super.initTargetSection(); fileTypeGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { checkFileType(); } }); checkFileType(); if (pcxRadio != null) { FxmlControl.setTooltip(pcxRadio, new Tooltip(message("PcxComments"))); } browseButton.setDisable(true); }
Example #12
Source File: ItemSelectionPane.java From ShootOFF with GNU General Public License v3.0 | 6 votes |
public void removeButton(T ref) { if (!items.containsKey(ref)) { logger.error("removeButton on non-existing ref - {}", ref); return; } final Node item = items.remove(ref); if (Platform.isFxApplicationThread()) { subContainer.getChildren().remove(item); } else { Platform.runLater(() -> subContainer.getChildren().remove(item)); } if (toggleable && ref == defaultSelection) { defaultSelection = null; } if (toggleable && ref == currentSelection && defaultSelection != null) { currentSelection = defaultSelection; itemListener.onItemClicked(currentSelection); toggleGroup.selectToggle((Toggle) items.get(currentSelection)); } }
Example #13
Source File: DaoLaunchWindow.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
private void addListeners() { currentSectionIndex.addListener((observable, oldValue, newValue) -> { if (!newValue.equals(oldValue)) { ObservableList<Toggle> toggles = sectionButtonsGroup.getToggles(); Toggle toggleToSelect = toggles.get(newValue.intValue() % toggles.size()); if (sectionButtonsGroup.getSelectedToggle() != toggleToSelect) sectionButtonsGroup.selectToggle(toggleToSelect); } }); sectionButtonsGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> { if (!newValue.equals(oldValue)) { int index = ((SectionButton) newValue).index; selectedSection = sections.get(index); if (showSlideInAnimation) slideInTimeline.playFromStart(); else slideOutTimeline.playFromStart(); currentSectionIndex.set(index); } }); }
Example #14
Source File: TemplateField.java From pattypan with MIT License | 6 votes |
public TemplateField(String name, String label, boolean isSelected, String constant) { this.name = name; this.label = label; this.isSelected = isSelected; this.selection = "YES"; this.value = constant; labelElement = new WikiLabel(label).setWidth(200, 500).setHeight(35); buttonYes.setSelected(true); group.selectedToggleProperty().addListener((ObservableValue<? extends Toggle> ov, Toggle tOld, Toggle tNew) -> { RadioButton btn = (RadioButton) tNew.getToggleGroup().getSelectedToggle(); setSelection(btn.getId()); }); valueText.setOnKeyReleased((KeyEvent event) -> { this.value = valueText.getText(); }); }
Example #15
Source File: GetNewSecret.java From strongbox with Apache License 2.0 | 6 votes |
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 #16
Source File: ImageManufactureEnhancementController.java From MyBox with Apache License 2.0 | 6 votes |
@Override public void initControls() { try { super.initControls(); myPane = enhancementPane; enhancementGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue ov, Toggle oldValue, Toggle newValue) { checkEnhanceType(); } }); manageView = new ImageView(); } catch (Exception e) { logger.error(e.toString()); } }
Example #17
Source File: SelectionGroup.java From megan-ce with GNU General Public License v3.0 | 5 votes |
public boolean selectAll(boolean select) { boolean changed = false; for (Toggle item : items) { if (item.isSelected() != select) { item.setSelected(select); changed = true; } } return changed; }
Example #18
Source File: Main.java From youtube-comment-suite with MIT License | 5 votes |
@Override public void initialize(URL location, ResourceBundle resources) { logger.debug("Initialize Main"); headerToggleGroup.getToggles().addListener((ListChangeListener<Toggle>) c -> { while (c.next()) { for (final Toggle addedToggle : c.getAddedSubList()) { ((ToggleButton) addedToggle).addEventFilter(MouseEvent.MOUSE_RELEASED, mouseEvent -> { if (addedToggle.equals(headerToggleGroup.getSelectedToggle())) mouseEvent.consume(); }); } } }); settingsIcon.setImage(ImageLoader.SETTINGS.getImage()); btnSettings.setOnAction(ae -> runLater(() -> { logger.debug("Open Settings"); settings.setManaged(true); settings.setVisible(true); })); btnSearchComments.setOnAction(ae -> runLater(() -> { headerIcon.setImage(ImageLoader.SEARCH.getImage()); content.getChildren().clear(); content.getChildren().add(searchComments); })); btnManageGroups.setOnAction(ae -> runLater(() -> { headerIcon.setImage(ImageLoader.MANAGE.getImage()); content.getChildren().clear(); content.getChildren().add(manageGroups); })); btnSearchYoutube.setOnAction(ae -> runLater(() -> { headerIcon.setImage(ImageLoader.YOUTUBE.getImage()); content.getChildren().clear(); content.getChildren().add(searchYoutube); })); btnManageGroups.fire(); }
Example #19
Source File: ConfigPropertyValueEditors.java From arma-dialog-creator with MIT License | 5 votes |
@Override public void setToValueFromProperty() { String newValue = configProperty.getValue().toString(); for (Toggle toggle : toggleGroup.getToggles()) { if (toggle.getUserData().equals(newValue)) { toggleGroup.selectToggle(toggle); return; } } }
Example #20
Source File: ChoiceButtonRepresentation.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private void selectionChanged(final ObservableValue<? extends Toggle> obs, final Toggle oldval, final Toggle newval) { if (!active && newval != null) { active = true; try { // For now reset to old value. // New value will be shown if the PV accepts it and sends a value update. toggle.selectToggle(oldval); if (enabled) { final Object value; final VType pv_value = model_widget.runtimePropValue().getValue(); if (pv_value instanceof VEnum || pv_value instanceof VNumber) // PV uses enumerated or numeric type, so write the index value = toggle.getToggles().indexOf(newval); else // PV uses text value = FormatOptionHandler.parse(pv_value, ((ButtonBase) newval).getText(), FormatOption.DEFAULT); logger.log(Level.FINE, "Writing " + value); Platform.runLater(() -> confirm(value)); } } finally { active = false; } } }
Example #21
Source File: SelectionGroup.java From megan-ce with GNU General Public License v3.0 | 5 votes |
public boolean isSelected() { for (Toggle item : items) { if (item.isSelected()) return true; } return false; }
Example #22
Source File: SelectionGroup.java From megan-ce with GNU General Public License v3.0 | 5 votes |
public ArrayList<Toggle> getSelectedItems() { final ArrayList<Toggle> selectedItems = new ArrayList<>(); for (Toggle item : items) { if (item.isSelected()) selectedItems.add(item); } return selectedItems; }
Example #23
Source File: ItemSelectionPane.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
public void setDefault(T ref) { if (!toggleable) { logger.error("setDefault only applies to toggleable item selection"); return; } if (items.containsKey(ref)) { if (defaultSelection == null && currentSelection == null) { currentSelection = ref; toggleGroup.selectToggle((Toggle) items.get(ref)); } defaultSelection = ref; } else logger.error("setDefault on non-existing ref - {}", ref); }
Example #24
Source File: ItemSelectionPane.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
public void setSelection(T ref) { if (items.containsKey(ref)) { currentSelection = ref; toggleGroup.selectToggle((Toggle) items.get(currentSelection)); } else { if (logger.isWarnEnabled()) logger.warn("setSelection on non-existing ref - {}", ref); } }
Example #25
Source File: JavaFXUtil.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void addAlwaysOneSelectedSupport(final ToggleGroup toggleGroup) { toggleGroup.getToggles().addListener((Change<? extends Toggle> c) -> { while (c.next()) { for (final Toggle addedToggle : c.getAddedSubList()) { addConsumeMouseEventfilter(addedToggle); } } }); toggleGroup.getToggles().forEach(t -> { addConsumeMouseEventfilter(t); }); }
Example #26
Source File: AttributeNode.java From constellation with Apache License 2.0 | 5 votes |
private void updateTranslatorGroupToggle() { for (MenuItem item1 : parseMenu.getItems()) { if (item1.getText().equals(translator.getLabel())) { menuGroup.selectToggle((Toggle) item1); break; } } }
Example #27
Source File: MissionCheck.java From logbook-kai with MIT License | 5 votes |
@FXML void update(ActionEvent event) { Toggle toggle = this.fleet.getToggleGroup().getSelectedToggle(); DeckPort deck = null; if (toggle != null) { deck = (DeckPort) toggle.getUserData(); } this.buildTree(deck); }
Example #28
Source File: LanguagePanel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void applyOptionValuesToControls() { GuiAssertions.assertIsNotJavaFXThread(); String origLanguage = ConfigurationSettings.getLanguage(); if ((origLanguage == null) || origLanguage.isEmpty()) { origLanguage = "system"; } for (Toggle button : languageChoiceGroup.getToggles()) { button.setSelected(button.getUserData() == origLanguage); } String currentUnitSet; if ((SettingsHandler.getGameAsProperty().get() != null) && (SettingsHandler.getGameAsProperty().get().getUnitSet() != null)) { currentUnitSet = SettingsHandler.getGameAsProperty().get().getUnitSet().getDisplayName(); } else { currentUnitSet = ""; } Platform.runLater(() -> { if (!unitSetType.getItems().isEmpty()) { unitSetType.setValue(currentUnitSet); } }); }
Example #29
Source File: HouseRulesPanel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void setOptionsBasedOnControls() { final GameMode gameMode = SettingsHandler.getGameAsProperty().get(); for (Map.Entry<RuleCheck, ButtonBase> settingsEntry : settings.entrySet()) { // Save settings if (gameMode.getModeContext().getReferenceContext().containsConstructedCDOMObject( RuleCheck.class, settingsEntry.getKey().getKeyName() )) { ButtonBase buttonBase = settingsEntry.getValue(); final boolean isSelected; // see https://github.com/javafxports/openjdk-jfx/issues/494 if (buttonBase instanceof RadioButton) { isSelected = ((Toggle) buttonBase).selectedProperty().get(); } else if (buttonBase instanceof CheckBox) { isSelected = ((CheckBox) buttonBase).selectedProperty().get(); } else { throw new IllegalStateException("button base that isn't of the right type " + buttonBase); } SettingsHandler.setRuleCheck(settingsEntry.getKey().getKeyName(), isSelected); } } }
Example #30
Source File: LatencyController.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
private void typeChanged( final ObservableValue<? extends Toggle> observable, final Toggle oldValue, final Toggle newValue ) { if (newValue == null) { oldValue.setSelected(true); } else { render(); } }