Monday, February 13, 2012

Implement ListView using JavaFX

Implement ListView using JavaFX
package javafx_ui;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_ui extends Application {

  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      launch(args);
  }

  @Override
  public void start(Stage primaryStage) {
      primaryStage.setTitle("http://java-buddy.blogspot.com/");
    
      ListView<String> listView = new ListView<>();
      ObservableList<String> list =FXCollections.observableArrayList (
              "Sunday",
              "Monday",
              "Tuesday",
              "Wednesday",
              "Thursday",
              "Friday",
              "Saturday");
      listView.setItems(list);
    
      StackPane root = new StackPane();
      root.getChildren().add(listView);
      primaryStage.setScene(new Scene(root, 300, 250));
      primaryStage.show();
  }
}


Related:
- Implement OnMouseClicked EventHandler for ListView
- Implement JavaFX ListView for custom object

No comments:

Post a Comment