Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public VBox thirdBox() {
- Button startButton = new Button("Start");
- startButton.setOnAction(actionEvent -> {
- paused = false;
- ogld.setWorld(world);
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- Runnable updater = new Runnable() {
- @Override
- public void run() {
- ogld.step();
- }
- };
- while (!paused) {
- try {
- Thread.sleep((long) i*1000);
- } catch (InterruptedException ex) {
- }
- // UI update is run on the Application thread
- Platform.runLater(updater);
- }
- }
- });
- // don't let thread prevent JVM shutdown
- thread.setDaemon(true);
- thread.start();
- });
- Button pause = new Button("Pause");
- pause.setOnAction(actionEvent -> {
- paused = true;
- });
- startButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
- pause.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
- VBox vbButtons = new VBox();
- vbButtons.setPadding(new Insets(10, 10, 10, 10));
- vbButtons.setSpacing(10);
- vbButtons.getChildren().addAll(startButton, pause);
- return vbButtons;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement