get JavaFX Combo Box String Value - Java JavaFX

Java examples for JavaFX:ComboBox

Description

get JavaFX Combo Box String Value

Demo Code


//package com.java2s;
import javafx.scene.control.ComboBox;

public class Main {
    public static String getComboBoxStringValue(ComboBox<String> comboBox) {
        return comboBox.getValue() == null ? comboBox.getPromptText()
                : comboBox.getSelectionModel().getSelectedItem();
    }// w ww .j  a va  2s  .com
}

Related Tutorials