Zookey90

newListView

May 20th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.collections.FXCollections;
  3. import javafx.collections.ObservableList;
  4. import javafx.event.EventHandler;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.ListView;
  7. import javafx.scene.input.MouseEvent;
  8.  
  9. import javafx.scene.layout.StackPane;
  10.  
  11. import javafx.stage.Stage;
  12. /**
  13.  *
  14.  * @author zoranpavlovic.blogspot.com
  15.  */
  16. public class ListViewMain extends Application {
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     StackPane sp = new StackPane();
  21.     ListView<String> list = new ListView<>();
  22.     ObservableList<String> data =FXCollections.observableArrayList (
  23.             "List index 0",
  24.             "List index 1",
  25.             "List index 2",
  26.             "List index 3",
  27.             "List index 4",
  28.             "List index 5");
  29.  
  30.     public static void main(String[] args) {
  31.         Application.launch(args);
  32.     }
  33.     @Override
  34.     public void start(Stage primaryStage) {
  35.         primaryStage.setTitle("JavaFX 2.0 ListView");
  36.  
  37.         //Adding data to ListView
  38.         list.setItems(data);
  39.            
  40.         //Adding BorderPane to the scene
  41.         sp.getChildren().add(list);
  42.         Scene scene = new Scene(sp,300,200);
  43.         primaryStage.setScene(scene);
  44.         primaryStage.show();
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment