Example usage for javafx.scene.control ChoiceBox getItems

List of usage examples for javafx.scene.control ChoiceBox getItems

Introduction

In this page you can find the example usage for javafx.scene.control ChoiceBox getItems.

Prototype

public final ObservableList<T> getItems() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    ChoiceBox choiceBox = new ChoiceBox(cursors);

    System.out.println(choiceBox.getItems());
    VBox box = new VBox();
    box.getChildren().add(choiceBox);/*ww  w . j  a  v  a 2 s. c o m*/
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
}

From source file:de.pixida.logtest.designer.automaton.EditorAutomaton.java

private void createConfigFrame() {
    final int descriptionInputLines = 8;
    this.descriptionInput.setPrefRowCount(descriptionInputLines);
    this.descriptionInput.setWrapText(true);
    this.descriptionInput.textProperty()
            .addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
                this.setDescription(newValue);
                this.graph.handleChange();
            });/*from  w ww  . ja  va  2s  .  co m*/
    this.configFrame.addOption("Description", this.descriptionInput);

    final ObservableList<String> options = FXCollections.observableArrayList("JavaScript", "python");
    if (!options.contains(Automaton.DEFAULT_SCRIPTING_LANGUAGE)) {
        options.add(0, Automaton.DEFAULT_SCRIPTING_LANGUAGE);
    }
    final ChoiceBox<String> scriptLanguageInput = new ChoiceBox<>(options);
    scriptLanguageInput
            .setValue(StringUtils.isBlank(this.scriptLanguage) || !options.contains(this.scriptLanguage)
                    ? Automaton.DEFAULT_SCRIPTING_LANGUAGE
                    : this.scriptLanguage);
    scriptLanguageInput.getSelectionModel().selectedIndexProperty()
            .addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> {
                EditorAutomaton.this.scriptLanguage = scriptLanguageInput.getItems().get((Integer) newValue);
                this.graph.handleChange();
            });
    this.configFrame.addOption("Script language", scriptLanguageInput);

    final int onLoadInputLines = 8;
    this.onLoadInput.setPrefRowCount(onLoadInputLines);
    this.onLoadInput.setWrapText(true);
    this.onLoadInput.setStyle("-fx-font-family: monospace");
    this.onLoadInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        this.graph.handleChange();
    });
    this.configFrame.addOption("On Load", this.onLoadInput);
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

public void createInputForHandlingOfNonHeadlineLines(final List<Triple<String, Node, String>> formItems) {
    final Map<HandlingOfNonHeadlineLines, String> mapValueToChoice = new HashMap<>();
    mapValueToChoice.put(HandlingOfNonHeadlineLines.FAIL,
            "Abort - Each line in the log file is assumed to be a log entry");
    mapValueToChoice.put(HandlingOfNonHeadlineLines.CREATE_MULTILINE_ENTRY,
            "Append to payload - This will create multiline payloads");
    mapValueToChoice.put(HandlingOfNonHeadlineLines.ASSUME_LAST_TIMESTAMP,
            "Create new log entry and use timestamp of recent log entry");
    mapValueToChoice.put(HandlingOfNonHeadlineLines.ASSUME_LAST_TIMESTAMP_AND_CHANNEL,
            "Create new log entry and use timestamp and channel of recent log entry");
    final ChoiceBox<HandlingOfNonHeadlineLines> handlingOfNonHeadlineLinesInput = new ChoiceBox<>(
            FXCollections.observableArrayList(HandlingOfNonHeadlineLines.values()));
    handlingOfNonHeadlineLinesInput.setConverter(new StringConverter<HandlingOfNonHeadlineLines>() {
        @Override/*from  w w  w  .  j  a v  a2 s  . co  m*/
        public String toString(final HandlingOfNonHeadlineLines object) {
            return mapValueToChoice.get(object);
        }

        @Override
        public HandlingOfNonHeadlineLines fromString(final String string) {
            for (final Entry<HandlingOfNonHeadlineLines, String> entry : mapValueToChoice.entrySet()) {
                if (entry.getValue() == string) // Intentionally comparing references to obtain a bijection
                {
                    return entry.getKey();
                }
            }
            return null; // Should never happen
        }
    });
    handlingOfNonHeadlineLinesInput.getSelectionModel().select(this.logReader.getHandlingOfNonHeadlineLines());
    handlingOfNonHeadlineLinesInput.getSelectionModel().selectedIndexProperty()
            .addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> {
                this.logReader.setHandlingOfNonHeadlineLines(
                        handlingOfNonHeadlineLinesInput.getItems().get(newValue.intValue()));
                this.setChanged(true);
            });
    formItems.add(Triple.of("Dangling Lines", handlingOfNonHeadlineLinesInput,
            "Define what to do if dangling lines are spotted. Dangling lines are lines which do not match the headline pattern, i.e."
                    + " which do not introduce a new log entry."));
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

public void initialiseVersionChoiceBox(ChoiceBox<String> choiceBox) {
    this.xpathVersionChoiceBox = choiceBox;

    ObservableList<String> versionItems = choiceBox.getItems();
    versionItems.add(XPathRuleQuery.XPATH_1_0);
    versionItems.add(XPathRuleQuery.XPATH_1_0_COMPATIBILITY);
    versionItems.add(XPathRuleQuery.XPATH_2_0);

    xpathVersionChoiceBox.getSelectionModel().select(XPathRuleQuery.XPATH_2_0);
    choiceBox.setConverter(DesignerUtil.stringConverter(s -> "XPath " + s, s -> s.substring(6)));
}