Skip to content

Instantly share code, notes, and snippets.

@KowalczykBartek
Created August 6, 2013 21:07
Show Gist options
  • Save KowalczykBartek/6168646 to your computer and use it in GitHub Desktop.
Save KowalczykBartek/6168646 to your computer and use it in GitHub Desktop.
public class SomeJavaApp extends Application {
ListView<String> list = new ListView<>();
ObservableList<String> items = FXCollections.observableArrayList();
@Override
public void start(Stage primaryStage) {
StackPane root = new StackPane();
root.getChildren().add(list);
Scene scene = new Scene(root, 400,400);
primaryStage.setTitle("I can use JavaFX LIST");
primaryStage.setScene(scene);
primaryStage.show();
Thread t = new Thread(new Runnable(){
@Override
public void run() {
for(int i=0; i<10; i++){
items.add(Integer.toString(i));
}
Platform.runLater(new Runnable() {
@Override public void run() {
list.setItems(items);
}
});
}
}
);
t.start();
}
public static void main(String[] args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment