Created
June 20, 2015 15:59
-
-
Save varren/aa12f1921922243a5509 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.collections.FXCollections; | |
import javafx.collections.ObservableList; | |
import javafx.scene.Scene; | |
import javafx.scene.control.*; | |
import javafx.stage.Stage; | |
public class SomeTestClass extends Application { | |
private static int counter = 0; | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
ObservableList<String> data = FXCollections.observableArrayList(); | |
ListView<String> list = new ListView<>(data); | |
new Thread(() -> { | |
while (true){ | |
try { | |
Thread.sleep(100); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
String newVal = "Some text " + String.valueOf(counter++); | |
Platform.runLater(() -> data.add(0,newVal)); | |
} | |
}).start(); | |
Scene scene = new Scene(list); | |
primaryStage.setScene(scene); | |
primaryStage.sizeToScene(); | |
primaryStage.show(); | |
} | |
public static void main(String[] args) { | |
Application.launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment