Guest User

FXML_Controller

a guest
Feb 13th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. /**
  2.  * Sample Skeleton for 'load_screen.fxml' Controller Class
  3.  */
  4.  
  5. package Loader;
  6.  
  7. import java.io.IOException;
  8. import java.net.MalformedURLException;
  9. import java.net.URL;
  10. import java.nio.file.Paths;
  11. import java.util.ResourceBundle;
  12. import java.util.concurrent.Executors;
  13. import java.util.concurrent.ScheduledExecutorService;
  14. import java.util.concurrent.TimeUnit;
  15. import java.util.concurrent.atomic.AtomicInteger;
  16.  
  17.  
  18. import javafx.fxml.FXMLLoader;
  19. import javafx.scene.text.Text;
  20.  
  21. public class Controller  implements Runnable {
  22.  
  23.     @FXML // ResourceBundle that was given to the FXMLLoader
  24.     private ResourceBundle resources;
  25.  
  26.     @FXML // URL location of the FXML file that was given to the FXMLLoader
  27.     private URL location;
  28.  
  29.     @FXML // fx:id="load_text"
  30.     private Text load_text; // Value injected by FXMLLoader
  31.  
  32.  
  33.     @Override
  34.     public void run() {
  35.         Platform.runLater(() ->  load_text.setText("Hello World"));
  36.        
  37.        
  38.     }
  39.  
  40.     @FXML
  41.     void initialize() throws IOException, InterruptedException {
  42.         Controller loader= new Controller();
  43.        Thread load=new Thread(loader);
  44.        load.start();
  45.         assert load_text != null : "fx:id=\"load_text\" was not injected: check your FXML file 'load_screen.fxml'.";
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment