Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package gui;
  2.  
  3. import javafx.fxml.FXML;
  4. import javafx.fxml.Initializable;
  5. import javafx.scene.control.Button;
  6.  
  7. import java.net.URL;
  8. import java.util.ResourceBundle;
  9. import java.util.concurrent.TimeUnit;
  10.  
  11. public class Controller implements Initializable {
  12.  
  13. private boolean buttonStatus = false;
  14. @FXML
  15. Button btn_switch;
  16.  
  17. @FXML
  18. Button btn_sound;
  19.  
  20. @Override
  21. public void initialize(URL location, ResourceBundle resources) {
  22. System.out.println(buttonStatus);
  23. //infiniteLoop();
  24. }
  25.  
  26. public void infiniteLoop() {
  27. while (true) {
  28. while (buttonStatus) {
  29. try {
  30. playSound();
  31. TimeUnit.SECONDS.sleep(5);
  32. } catch (InterruptedException e) {
  33. e.printStackTrace();
  34. }
  35. }
  36. }
  37. }
  38.  
  39. public void playSound() {
  40. System.out.println("Playing sound.");
  41. }
  42.  
  43. public void toggleButton() {
  44. buttonStatus = !buttonStatus;
  45. System.out.println("Toggled button! " + buttonStatus);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement