Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. package address;
  2.  
  3. import javafx.application.Preloader;
  4. import javafx.geometry.Pos;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.Label;
  7. import javafx.scene.image.ImageView;
  8. import javafx.scene.layout.BorderPane;
  9. import javafx.scene.layout.VBox;
  10. import javafx.scene.paint.Color;
  11. import javafx.stage.Stage;
  12. import javafx.stage.StageStyle;
  13.  
  14.  
  15. /**
  16. * AddressApp Preloader.
  17. * @author htha9587
  18. *
  19. */
  20. public class MainLoader extends Preloader {
  21.  
  22. private Stage stage;
  23.  
  24. private Scene createPreloaderScene()
  25. {
  26. String url = getClass().getResource("loader.GIF").toExternalForm();
  27. ImageView progress = new ImageView(url);
  28.  
  29. Label title = new Label("AddressApp");
  30. title.setStyle("-fx-font-size: 2.3em; -fx-text-fill: whitesmoke;");
  31.  
  32. Label footer = new Label("Author: Harrison Thacker");
  33. footer.setStyle("-fx-font-size: 0.5em; -fx-text-fill: whitesmoke; -fx-font-style: oblique;");
  34.  
  35. VBox root = new VBox();
  36. root.setSpacing(10.0);
  37. root.setAlignment(Pos.CENTER);
  38. root.getChildren().addAll(title, progress);
  39.  
  40. BorderPane pane = new BorderPane(root);
  41. pane.setBottom(footer);
  42. pane.setStyle("-fx-background-color: #2b579a");
  43.  
  44. return new Scene(pane, 480, 320, Color.TRANSPARENT);
  45. }
  46.  
  47.  
  48. @Override
  49. public void start(Stage stage) throws Exception
  50. {
  51. this.stage = stage;
  52.  
  53.  
  54. stage.initStyle(StageStyle.TRANSPARENT);
  55. stage.setScene(createPreloaderScene());
  56. stage.show();
  57. }
  58.  
  59. @Override
  60. public void handleStateChangeNotification(StateChangeNotification scn)
  61. {
  62. if(scn.getType() == StateChangeNotification.Type.BEFORE_START)
  63. {
  64. stage.hide();
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement