JAVAFX combo box

Illustration with a combo box in the anchor pane

sample.fxml



<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.layout.AnchorPane?>

<?import javafx.collections.FXCollections?>
<?import java.lang.String?>
<AnchorPane maxHeight="-Infinity"
            maxWidth="-Infinity"
            minHeight="-Infinity"
            minWidth="-Infinity"
            prefHeight="400.0"
            prefWidth="600.0"
            xmlns:fx="http://javafx.com/fxml/1">
    <ComboBox layoutX="36.0" layoutY="50.0" prefWidth="150.0" >
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
                <String fx:value="Item 4" />
                <String fx:value="Item 5" />
            </FXCollections>
        </items>
    </ComboBox>
</AnchorPane>

You can write the contents of the combo box with FXML

combobox.png

Recommended Posts

JAVAFX combo box
JavaFX text
JavaFx memorandum