javafx.scene.control.ChoiceBox Java Examples
The following examples show how to use
javafx.scene.control.ChoiceBox.
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: MarkdownOptionsPane.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 6 votes |
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents markdownRendererLabel = new Label(); markdownRendererChoiceBox = new ChoiceBox<>(); markdownExtensionsLabel = new Label(); markdownExtensionsPane = new MarkdownExtensionsPane(); //======== this ======== setLayout("insets dialog"); setCols("[][grow,fill]"); setRows("[]para[][grow,fill]"); //---- markdownRendererLabel ---- markdownRendererLabel.setText(Messages.get("MarkdownOptionsPane.markdownRendererLabel.text")); add(markdownRendererLabel, "cell 0 0"); add(markdownRendererChoiceBox, "cell 1 0,alignx left,growx 0"); //---- markdownExtensionsLabel ---- markdownExtensionsLabel.setText(Messages.get("MarkdownOptionsPane.markdownExtensionsLabel.text")); add(markdownExtensionsLabel, "cell 0 1 2 1"); add(markdownExtensionsPane, "pad 0 indent 0 0,cell 0 2 2 1"); // JFormDesigner - End of component initialization //GEN-END:initComponents }
Example #2
Source File: UiKeyTriggerGrid.java From EWItool with GNU General Public License v3.0 | 6 votes |
UiKeyTriggerGrid( EWI4000sPatch editPatch, MidiHandler midiHandler ) { setId( "editor-grid" ); Label mainLabel = new Label( "Key Trigger" ); mainLabel.setId( "editor-section-label" ); GridPane.setColumnSpan( mainLabel, 2 ); add( mainLabel, 0, 0 ); keyTriggerChoice = new ChoiceBox<String>(); keyTriggerChoice.getItems().addAll( "Single", "Multi" ); keyTriggerChoice.setOnAction( (event) -> { midiHandler.sendLiveControl( 7, 81, keyTriggerChoice.getSelectionModel().getSelectedIndex() ); editPatch.formantFilter = keyTriggerChoice.getSelectionModel().getSelectedIndex(); }); add( keyTriggerChoice, 0, 1 ); }
Example #3
Source File: RFXChoiceBoxTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void selectOptionWithQuotes() { @SuppressWarnings("unchecked") ChoiceBox<String> choiceBox = (ChoiceBox<String>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getItems().add(" \"Mouse \" "); choiceBox.getSelectionModel().select(" \"Mouse \" "); rfxChoiceBox.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals(" \"Mouse \" ", recording.getParameters()[0]); }
Example #4
Source File: RFXChoiceBoxTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void htmlOptionSelect() { @SuppressWarnings("unchecked") ChoiceBox<String> choiceBox = (ChoiceBox<String>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); String text = "This is a test text"; final String htmlText = "<html><font color=\"RED\"><h1><This is also content>" + text + "</h1></html>"; Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getItems().add(htmlText); choiceBox.getSelectionModel().select(htmlText); rfxChoiceBox.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals(text, recording.getParameters()[0]); }
Example #5
Source File: RFXChoiceBoxTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void getText() { ChoiceBox<?> choiceBox = (ChoiceBox<?>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getSelectionModel().select(1); rfxChoiceBox.focusLost(null); text.add(rfxChoiceBox._getText()); }); new Wait("Waiting for choice box text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("Cat", text.get(0)); }
Example #6
Source File: FormPane.java From marathonv5 with Apache License 2.0 | 6 votes |
private void setFormConstraints(Node field) { if (field instanceof ISetConstraints) { ((ISetConstraints) field).setFormConstraints(this); } else if (field instanceof Button) { _setFormConstraints((Button) field); } else if (field instanceof TextField) { _setFormConstraints((TextField) field); } else if (field instanceof TextArea) { _setFormConstraints((TextArea) field); } else if (field instanceof ComboBox<?>) { _setFormConstraints((ComboBox<?>) field); } else if (field instanceof ChoiceBox<?>) { _setFormConstraints((ChoiceBox<?>) field); } else if (field instanceof CheckBox) { _setFormConstraints((CheckBox) field); } else if (field instanceof Spinner<?>) { _setFormConstraints((Spinner<?>) field); } else if (field instanceof VBox) { _setFormConstraints((VBox) field); } else if (field instanceof Label) { _setFormConstraints((Label) field); } else { LOGGER.info("FormPane.setFormConstraints(): unknown field type: " + field.getClass().getName()); } }
Example #7
Source File: UiFormantGrid.java From EWItool with GNU General Public License v3.0 | 6 votes |
UiFormantGrid( EWI4000sPatch editPatch, MidiHandler midiHandler ) { setId( "editor-grid" ); Label mainLabel = new Label( "Formant Filter" ); mainLabel.setId( "editor-section-label" ); GridPane.setValignment( mainLabel, VPos.TOP ); add( mainLabel, 0, 0 ); formantChoice = new ChoiceBox<String>(); formantChoice.getItems().addAll( "Off", "Woodwind", "Strings" ); formantChoice.setOnAction( (event) -> { midiHandler.sendLiveControl( 5, 81, formantChoice.getSelectionModel().getSelectedIndex() ); editPatch.formantFilter = formantChoice.getSelectionModel().getSelectedIndex(); }); add( formantChoice, 0, 1 ); }
Example #8
Source File: DataManipulationUI.java From SONDY with GNU General Public License v3.0 | 6 votes |
public final void initializePreprocessedCorpusList(){ preprocessedCorpusList = new ChoiceBox(); UIUtils.setSize(preprocessedCorpusList, Main.columnWidthRIGHT, 24); preprocessedCorpusList.setItems(AppParameters.dataset.preprocessedCorpusList); preprocessedCorpusList.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue ov, String t, String t1) { clearFilterUI(); if(t1 != null){ LogUI.addLogEntry("Loading '"+AppParameters.dataset.id+"' ("+t1+")... "); AppParameters.dataset.corpus.loadFrequencies(t1); AppParameters.timeSliceA = 0; AppParameters.timeSliceB = AppParameters.dataset.corpus.messageDistribution.length; LogUI.addLogEntry("Done."); resizeSlider.setMin(0); resizeSlider.setLowValue(0); resizeSlider.setMax(AppParameters.dataset.corpus.getLength()); resizeSlider.setHighValue(AppParameters.dataset.corpus.getLength()); } } }); }
Example #9
Source File: GUITest.java From density-converter with Apache License 2.0 | 6 votes |
@Ignore public void testUpScalingQuality() throws Exception { for (EScalingAlgorithm algo : EScalingAlgorithm.getAllEnabled()) { if (algo.getSupportedForType().contains(EScalingAlgorithm.Type.UPSCALING)) { ChoiceBox choiceBox = (ChoiceBox) scene.lookup("#choiceUpScale"); //choiceBox.getSelectionModel(). for (Object o : choiceBox.getItems()) { if (o.toString().equals(algo.toString())) { } } clickOn("#choiceUpScale").clickOn(algo.toString()); assertEquals("arguments should match", defaultBuilder.upScaleAlgorithm(algo).build(), controller.getFromUI(false)); } } }
Example #10
Source File: CellUtils.java From ARMStrong with Mozilla Public License 2.0 | 5 votes |
/*************************************************************************** * * * ChoiceBox convenience * * * **************************************************************************/ static <T> void updateItem(final Cell<T> cell, final StringConverter<T> converter, final ChoiceBox<T> choiceBox) { updateItem(cell, converter, null, null, choiceBox); }
Example #11
Source File: ChoiceBoxSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ChoiceBoxSample() { super(150,100); ChoiceBox cb = new ChoiceBox(); cb.getItems().addAll("Dog", "Cat", "Horse"); cb.getSelectionModel().selectFirst(); getChildren().add(cb); }
Example #12
Source File: BrowserTab.java From marathonv5 with Apache License 2.0 | 5 votes |
public void addIELogLevel() { ieLogLevel = new ChoiceBox<>(); ieLogLevel.getItems().add(null); ieLogLevel.getItems().addAll(FXCollections.observableArrayList(InternetExplorerDriverLogLevel.values())); String value = BrowserConfig.instance().getValue(getBrowserName(), "webdriver-ie-log-level"); if (value != null) ieLogLevel.getSelectionModel().select(InternetExplorerDriverLogLevel.valueOf(value)); advancedPane.addFormField("Log Level:", ieLogLevel); }
Example #13
Source File: ParameterSetupDialog.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
protected void addListenersToNode(Node node) { if (node instanceof TextField) { TextField textField = (TextField) node; textField.textProperty().addListener(((observable, oldValue, newValue) -> { parametersChanged(); })); } if (node instanceof ComboBox) { ComboBox<?> comboComp = (ComboBox<?>) node; comboComp.valueProperty() .addListener(((observable, oldValue, newValue) -> parametersChanged())); } if (node instanceof ChoiceBox) { ChoiceBox<?> choiceBox = (ChoiceBox) node; choiceBox.valueProperty() .addListener(((observable, oldValue, newValue) -> parametersChanged())); } if (node instanceof CheckBox) { CheckBox checkBox = (CheckBox) node; checkBox.selectedProperty() .addListener(((observable, oldValue, newValue) -> parametersChanged())); } if (node instanceof Region) { Region panelComp = (Region) node; for (int i = 0; i < panelComp.getChildrenUnmodifiable().size(); i++) { Node child = panelComp.getChildrenUnmodifiable().get(i); if (!(child instanceof Control)) { continue; } addListenersToNode(child); } } }
Example #14
Source File: JavaFXChoiceBoxElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public boolean marathon_select(String value) { ChoiceBox<?> choiceBox = (ChoiceBox<?>) getComponent(); String text = stripHTMLTags(value); int selectedItem = getChoiceBoxItemIndex(choiceBox, text); if (selectedItem == -1) { return false; } choiceBox.getSelectionModel().select(selectedItem); return true; }
Example #15
Source File: BrowserTab.java From marathonv5 with Apache License 2.0 | 5 votes |
public void addUnexpectedAlertBehavior() { unexpectedAlertBehaviour = new ChoiceBox<>(); unexpectedAlertBehaviour.getItems().add(null); unexpectedAlertBehaviour.getItems().addAll(FXCollections.observableArrayList(UnexpectedAlertBehaviour.values())); String value = BrowserConfig.instance().getValue(getBrowserName(), "browser-unexpected-alert-behaviour"); if (value != null) unexpectedAlertBehaviour.getSelectionModel().select(UnexpectedAlertBehaviour.fromString(value)); advancedPane.addFormField("Unexpected alert behaviour:", unexpectedAlertBehaviour); }
Example #16
Source File: ConfigurationUIController.java From jace with GNU General Public License v2.0 | 5 votes |
private Node buildDynamicSelectComponent(ConfigNode node, String settingName, Serializable value) { try { DynamicSelection sel = (DynamicSelection) node.subject.getClass().getField(settingName).get(node.subject); ChoiceBox widget = new ChoiceBox(FXCollections.observableList(new ArrayList(sel.getSelections().keySet()))); widget.setMinWidth(175.0); widget.setConverter(new StringConverter() { @Override public String toString(Object object) { return (String) sel.getSelections().get(object); } @Override public Object fromString(String string) { return sel.findValueByMatch(string); } }); Object selected = value == null ? null : widget.getConverter().fromString(String.valueOf(value)); if (selected == null) { widget.getSelectionModel().selectFirst(); } else { widget.setValue(selected); } widget.valueProperty().addListener((Observable e) -> { node.setFieldValue(settingName, widget.getConverter().toString(widget.getValue())); }); return widget; } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(ConfigurationUIController.class.getName()).log(Level.SEVERE, null, ex); return null; } }
Example #17
Source File: ToolbarComponent.java From milkman with MIT License | 5 votes |
public void changed(ChoiceboxEntry o, ChoiceboxEntry n, ChoiceBox<ChoiceboxEntry> choiceBox) { if (n != null) n.invoke(); if (o != null && n != null && !n.isSelectable()) { //select old value, if this one is unselectable Platform.runLater(() -> choiceBox.setValue(o)); } }
Example #18
Source File: CellUtils.java From ARMStrong with Mozilla Public License 2.0 | 5 votes |
static <T> ChoiceBox<T> createChoiceBox( final Cell<T> cell, final ObservableList<T> items, final ObjectProperty<StringConverter<T>> converter) { ChoiceBox<T> choiceBox = new ChoiceBox<T>(items); choiceBox.setMaxWidth(Double.MAX_VALUE); choiceBox.converterProperty().bind(converter); choiceBox.showingProperty().addListener(o -> { if (!choiceBox.isShowing()) { cell.commitEdit(choiceBox.getSelectionModel().getSelectedItem()); } }); return choiceBox; }
Example #19
Source File: JavaFXChoiceBoxElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) { if (selector.equals("nth-option")) { return Arrays.asList(new JavaFXChoiceBoxOptionElement(this, ((Integer) params[0]).intValue() - 1)); } else if (selector.equals("all-options") || selector.equals("all-cells")) { ChoiceBox<?> listView = (ChoiceBox<?>) getComponent(); ArrayList<IJavaFXElement> r = new ArrayList<>(); int nItems = listView.getItems().size(); for (int i = 0; i < nItems; i++) { r.add(new JavaFXChoiceBoxOptionElement(this, i)); } return r; } return super.getByPseudoElement(selector, params); }
Example #20
Source File: JavaFXChoiceBoxElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void select() { ChoiceBox<?> choiceBoxNode = (ChoiceBox<?>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); Platform.runLater(() -> { choiceBox.marathon_select("Cat"); }); new Wait("Waiting for choice box option to be set.") { @Override public boolean until() { return choiceBoxNode.getSelectionModel().getSelectedIndex() == 1; } }; }
Example #21
Source File: ChoiceBoxSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ChoiceBoxSample() { super(150,100); ChoiceBox cb = new ChoiceBox(); cb.getItems().addAll("Dog", "Cat", "Horse"); cb.getSelectionModel().selectFirst(); getChildren().add(cb); }
Example #22
Source File: ChoiceBoxSample.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); scene.setFill(Color.ALICEBLUE); stage.setScene(scene); stage.show(); stage.setTitle("ChoiceBox Sample"); stage.setWidth(300); stage.setHeight(200); label.setFont(Font.font("Arial", 25)); label.setLayoutX(40); final String[] greetings = new String[] { "Hello", "Hola", "Привет", "你好", "こんにちは" }; final ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList("English", "Español", "Русский", "简体中文", "日本語")); cb.getSelectionModel().selectedIndexProperty() .addListener((ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> { label.setText(greetings[new_val.intValue()]); }); cb.setTooltip(new Tooltip("Select the language")); cb.setValue("English"); HBox hb = new HBox(); hb.getChildren().addAll(cb, label); hb.setSpacing(30); hb.setAlignment(Pos.CENTER); hb.setPadding(new Insets(10, 0, 0, 10)); ((Group) scene.getRoot()).getChildren().add(hb); }
Example #23
Source File: RFXMenuItem.java From marathonv5 with Apache License 2.0 | 5 votes |
public void record(ActionEvent event) { MenuItem source = (MenuItem) event.getSource(); String tagForMenu = getTagForMenu(source); String menuPath = getSelectedMenuPath(source); if (!(ownerNode instanceof ChoiceBox<?>) && ownerNode != null) { recorder.recordSelectMenu(new RFXUnknownComponent(ownerNode, oMapConfig, null, recorder), tagForMenu, menuPath); } }
Example #24
Source File: RFXChoiceBox.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void focusLost(RFXComponent next) { ChoiceBox<?> choiceBox = (ChoiceBox<?>) node; Object selectedItem = choiceBox.getSelectionModel().getSelectedItem(); if (selectedItem != null && selectedItem.equals(prevSelectedItem)) { return; } String text = getChoiceBoxText(choiceBox, choiceBox.getSelectionModel().getSelectedIndex()); if (text != null) { recorder.recordSelect(this, text); } }
Example #25
Source File: RFXChoiceBoxTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void select() { ChoiceBox<?> choiceBox = (ChoiceBox<?>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getSelectionModel().select(1); rfxChoiceBox.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Cat", recording.getParameters()[0]); }
Example #26
Source File: CellUtiles.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/*************************************************************************** * * * ChoiceBox convenience * * * **************************************************************************/ static <T> void updateItem(final Cell<T> cell, final StringConverter<T> converter, final ChoiceBox<T> choiceBox) { updateItem(cell, converter, null, null, choiceBox); }
Example #27
Source File: CellUtiles.java From phoebus with Eclipse Public License 1.0 | 5 votes |
static <T> void updateItem(final Cell<T> cell, final StringConverter<T> converter, final HBox hbox, final Node graphic, final ChoiceBox<T> choiceBox) { if (cell.isEmpty()) { cell.setText(null); cell.setGraphic(null); } else { if (cell.isEditing()) { if (choiceBox != null) { choiceBox.getSelectionModel().select(cell.getItem()); } cell.setText(null); if (graphic != null) { hbox.getChildren().setAll(graphic, choiceBox); cell.setGraphic(hbox); } else { cell.setGraphic(choiceBox); } } else { cell.setText(getItemText(cell, converter)); cell.setGraphic(graphic); } } }
Example #28
Source File: CellUtiles.java From phoebus with Eclipse Public License 1.0 | 5 votes |
static <T> ChoiceBox<T> createChoiceBox( final Cell<T> cell, final ObservableList<T> items, final ObjectProperty<StringConverter<T>> converter) { ChoiceBox<T> choiceBox = new ChoiceBox<T>(items); choiceBox.setMaxWidth(Double.MAX_VALUE); choiceBox.converterProperty().bind(converter); choiceBox.getSelectionModel().selectedItemProperty().addListener((ov, oldValue, newValue) -> { if (cell.isEditing()) { cell.commitEdit(newValue); } }); return choiceBox; }
Example #29
Source File: KeyPatchesTab.java From EWItool with GNU General Public License v3.0 | 5 votes |
void populateChoices() { String[] pNames = new String[EWI4000sPatch.EWI_NUM_PATCHES]; for (int p = 0; p < EWI4000sPatch.EWI_NUM_PATCHES; p++) { pNames[p] = sharedData.ewiPatchList[p].getName(); } for ( ChoiceBox<String> keyChoice : keyPatchesGrid.keyChoices ) { keyChoice.getItems().clear(); keyChoice.getItems().addAll( pNames ); } }
Example #30
Source File: ChoiceBoxDemo.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@Override public void start(Stage primaryStage) throws Exception { VBox vbox = new VBox(); vbox.setPadding(new Insets(10)); vbox.setAlignment(Pos.CENTER); vbox.setSpacing(10); Label label = new Label("Make Yes/No Selection"); ChoiceBox<Pair<String, String>> cb = new ChoiceBox<>(); cb.setItems( Constants.LIST_YES_NO ); cb.setConverter( new PairStringConverter() ); cb.setValue( Constants.PAIR_NO ); Label labelOpt = new Label("Make Yes/No Selection (Optional)"); ChoiceBox<Pair<String, String>> cbOpt = new ChoiceBox<>(); cbOpt.setItems( Constants.LIST_YES_NO_OPT ); cbOpt.setConverter(new PairStringConverter(true) ); cbOpt.setValue( Constants.PAIR_NULL ); Button b = new Button("Save"); b.setOnAction( (evt) -> System.out.println("Selections - yes/no was '" + cb.getValue() + "' and yes/no/opt was '" + cbOpt.getValue() + "'") ); vbox.getChildren().addAll(label, cb, labelOpt, cbOpt, b); Scene scene = new Scene(vbox); primaryStage.setTitle("Choice Box Demo"); primaryStage.setHeight(200); primaryStage.setWidth(300); primaryStage.setScene( scene ); primaryStage.show(); }