Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- import javafx.event.EventHandler;
- import javafx.scene.Scene;
- import javafx.scene.control.ListView;
- import javafx.scene.input.MouseEvent;
- import javafx.scene.layout.StackPane;
- import javafx.stage.Stage;
- /**
- *
- * @author zoranpavlovic.blogspot.com
- */
- public class ListViewMain extends Application {
- /**
- * @param args the command line arguments
- */
- StackPane sp = new StackPane();
- ListView<String> list = new ListView<>();
- ObservableList<String> data =FXCollections.observableArrayList (
- "List index 0",
- "List index 1",
- "List index 2",
- "List index 3",
- "List index 4",
- "List index 5");
- public static void main(String[] args) {
- Application.launch(args);
- }
- @Override
- public void start(Stage primaryStage) {
- primaryStage.setTitle("JavaFX 2.0 ListView");
- //Adding data to ListView
- list.setItems(data);
- //Adding BorderPane to the scene
- sp.getChildren().add(list);
- Scene scene = new Scene(sp,300,200);
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment