import javafx.application.Application; import javafx.geometry.Insets; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ComboBox; import javafx.scene.layout.VBox; public class App extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { ComboBox combobox = new ComboBox<>(); combobox.getItems().add("alma"); combobox.getItems().add("körte"); combobox.getItems().add("barack"); combobox.getItems().addAll("szilva", "banán", "citrom"); combobox.setValue("barack"); Button button = new Button("Mehet"); button.setOnAction(e -> { System.out.println(combobox.getValue()); }); VBox vbox = new VBox(10); vbox.setPadding(new Insets(10, 10, 10, 10)); vbox.getChildren().addAll(combobox, button); Scene scene = new Scene(vbox, 300, 250); primaryStage.setScene(scene); primaryStage.show(); } }