Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. public VBox thirdBox() {
  2. Button startButton = new Button("Start");
  3. startButton.setOnAction(actionEvent -> {
  4. paused = false;
  5. ogld.setWorld(world);
  6.  
  7. Thread thread = new Thread(new Runnable() {
  8.  
  9. @Override
  10. public void run() {
  11. Runnable updater = new Runnable() {
  12. @Override
  13. public void run() {
  14. ogld.step();
  15. }
  16. };
  17.  
  18. while (!paused) {
  19. try {
  20. Thread.sleep((long) i*1000);
  21. } catch (InterruptedException ex) {
  22. }
  23. // UI update is run on the Application thread
  24. Platform.runLater(updater);
  25. }
  26. }
  27.  
  28. });
  29. // don't let thread prevent JVM shutdown
  30. thread.setDaemon(true);
  31. thread.start();
  32.  
  33. });
  34. Button pause = new Button("Pause");
  35. pause.setOnAction(actionEvent -> {
  36. paused = true;
  37. });
  38.  
  39. startButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
  40. pause.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
  41. VBox vbButtons = new VBox();
  42. vbButtons.setPadding(new Insets(10, 10, 10, 10));
  43. vbButtons.setSpacing(10);
  44. vbButtons.getChildren().addAll(startButton, pause);
  45. return vbButtons;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement