Last active
December 18, 2015 23:39
-
-
Save KowalczykBartek/5863075 to your computer and use it in GitHub Desktop.
javafx sample
This file contains 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
public class JavafxSampleLIST 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 MessageLoop()); | |
t.start(); | |
} | |
private class MessageLoop implements 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); | |
} | |
}); | |
} | |
} | |
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