import javafx.application.Application; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ListView; import javafx.scene.control.SelectionMode; 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 { ListView list = new ListView<>(); list.getItems().setAll("alma", "körte", "barack", "szilva"); list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); Button button = new Button("Mehet"); button.setOnAction(e -> { ObservableList obsList; obsList = list.getSelectionModel().getSelectedItems(); for (String item : obsList) { System.out.println(item); } }); VBox vbox = new VBox(10); vbox.setPadding(new Insets(10, 10, 10, 10)); vbox.getChildren().addAll(list, button); Scene scene = new Scene(vbox, 300, 250); primaryStage.setScene(scene); primaryStage.show(); } }