JavaFX Splash Screen / Welcome Screen (Inside Same Window)

Поділитися
Вставка
  • Опубліковано 18 вер 2024

КОМЕНТАРІ • 25

  • @CHITUS
    @CHITUS 2 роки тому +1

    Thank You very useful for me

  • @alexweissnicht9545
    @alexweissnicht9545 5 років тому

    How do I update an ProgressBar animated? I want to set the progress using a Task and it would be cool if there would be a transition if he updated the progress :-)

  • @JohnCena12355
    @JohnCena12355 8 років тому

    THANK YOU! this was very helpful! How can I use a loading gif for the splash screen (without fade)? When I put it on the stackpane I couldn't see it

    • @GenuineCoder
      @GenuineCoder  8 років тому

      Hi,
      I have made a new video on making more realistic Splash Screen. ua-cam.com/video/f06uUtkmtDE/v-deo.html
      Instead of using JPEG image as the background (Inside ImageView), Just select a GIF image.You will get animated gif splash screen.
      I have tried it. :-)

    • @isaiahdante7362
      @isaiahdante7362 3 роки тому

      A tip : watch movies at flixzone. Me and my gf have been using them for watching all kinds of movies during the lockdown.

  • @talhajanab7910
    @talhajanab7910 8 років тому +1

    Thank You Sir...
    Thanks a Lot................................

  • @adarshdev3810
    @adarshdev3810 7 років тому

    it did work but i am gettina troble when the second frame is loaded it is just on one corner

    • @GenuineCoder
      @GenuineCoder  7 років тому

      What is the sizeof second frame ?
      Is it same as that of first?

  • @someone2939
    @someone2939 Рік тому

    you are the best!

  • @joseemasyah9764
    @joseemasyah9764 8 років тому +1

    Thanks!!!

  • @luketimewalker7192
    @luketimewalker7192 6 років тому

    Thank you. That helped me alot

  • @saifrao3498
    @saifrao3498 8 років тому

    Thanks buddy its really helpfull

  • @kobibi19
    @kobibi19 5 років тому

    Thank you!

  • @kps2642
    @kps2642 6 років тому

    Thank you very much sir

  • @erfelipe
    @erfelipe 7 років тому

    Thank you.

  • @umeshchauhan8664
    @umeshchauhan8664 6 років тому

    Plzz help me i m getting and exception... Plzz give me ur mail genuine coders..

  • @peterpan292
    @peterpan292 7 років тому

    Link does not work

  • @donykisworo6709
    @donykisworo6709 8 років тому

    How use splash screen and then login frame and then main frame, can or not ?

    • @GenuineCoder
      @GenuineCoder  8 років тому

      Hi,Of course you can do that!
      After the fade-out transition, load your Login fxml file. After successful login, load your main frame fxml.

    • @donykisworo6709
      @donykisworo6709 8 років тому

      I tried your example on youtube about splash with separate windows, which splash into the menu (you select the table) be set to hide ().I try to apply splash to login is ok but on the login moved to the menu crash occurred due to splash arranged in splashcontroller with layout to hide ().which in my login set to close ().If I make two fxml no problem but when more than 2 fxml certainly problematic.Is JavaFX is problematic with 3 fxml?Because I try to login splash and I use my alerts (fxml) itself is also problematic (not the default alert of JavaFX)Are you able to help you so see how it should apply.Note: I am not able to implement the close () in a splash because it took the event to be taken by the node

    • @GenuineCoder
      @GenuineCoder  8 років тому

      Can you post the code here ?

    • @donykisworo6709
      @donykisworo6709 8 років тому

      Main.java
      package com.main;
      import com.djcom.view.MainMenuController;
      import com.djcom.view.LoginController;
      import com.djcom.view.SplashController;
      import java.io.IOException;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Scene;
      import javafx.scene.layout.AnchorPane;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;
      public class Main extends Application {
      private Stage primaryStage;
      public AnchorPane firstLayout;
      @Override
      public void start(Stage primaryStage) {
      this.primaryStage = primaryStage;
      this.primaryStage.setTitle("Aplikasi Test");
      initRootLayout();
      }
      public void initRootLayout() {
      {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(Main.class
      .getResource("view/Splash.fxml"));
      firstLayout = (AnchorPane) loader.load();
      Scene scene = new Scene(firstLayout);
      primaryStage.initStyle(StageStyle.UNDECORATED);
      primaryStage.setScene(scene);

      SplashController controller = loader.getController();
      controller.setMain(this);
      primaryStage.show();
      } catch (IOException e) {
      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
      }
      }
      public void showLogin() {
      try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(Main.class
      .getResource("view/Login.fxml"));
      AnchorPane page = (AnchorPane) loader.load();
      Scene scene = new Scene(page);
      primaryStage.setTitle("User Login");
      primaryStage.centerOnScreen();
      primaryStage.setScene(scene);
      primaryStage.show();
      LoginController controller = loader.getController();
      controller.setMain(this);
      } catch (IOException e) {
      e.printStackTrace();
      }
      }
      public void showMain() {
      try {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(Main.class
      .getResource("view/MainMenu.fxml"));
      rootLayout = (BorderPane) loader.load();
      Scene scene = new Scene(rootLayout);
      primaryStage.setScene(scene);

      FrameUtamaController controller = loader.getController();
      controller.setMain(this);
      primaryStage.show();
      } catch (IOException e) {
      e.printStackTrace();
      }
      public Stage getPrimaryStage() {
      return primaryStage;
      }
      public static void main(String[] args) {
      launch(args);
      }
      }
      SplashController.java
      package com.view;
      import com.main.Main;
      import java.io.IOException;
      import java.net.URL;
      import java.util.ResourceBundle;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javafx.application.Platform;
      import javafx.fxml.FXML;
      import javafx.fxml.FXMLLoader;
      import javafx.fxml.Initializable;
      import javafx.scene.Scene;
      import javafx.scene.layout.AnchorPane;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;
      public class SplashController implements Initializable {
      private Main Main;
      private AnchorPane secondLayout;
      @FXML
      private AnchorPane firstLayout;
      @Override
      public void initialize(URL url, ResourceBundle rb) {
      new SplashScreen().start();
      }
      public void setMain(Main Main) {
      this.Main = Main;
      }
      class SplashScreen extends Thread {
      @Override
      public void run(){
      try {
      Thread.sleep(5000);
      Platform.runLater(new Runnable(){
      @Override
      public void run(){
      AnchorPane secondLayout=null;
      try{
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(Main.class
      .getResource("view/Login.fxml"));
      secondLayout = (AnchorPane) loader.load();
      }catch (IOException ex) {
      Logger.getLogger(SplashController.class.getName()).log(Level.SEVERE, null, ex);
      }
      Scene scene = new Scene(secondLayout);
      Stage stagen = new Stage();
      stagen.setScene(scene);
      stagen.initStyle(StageStyle.UNDECORATED);
      stagen.show();

      firstLayout.getScene().getWindow().hide();


      }
      });
      } catch (InterruptedException ex) {
      Logger.getLogger(SplashController.class.getName()).log(Level.SEVERE, null, ex);
      }
      }
      }
      }
      LoginController.java
      package com.view;
      import com.main.Main;
      import java.io.IOException;
      import java.util.ResourceBundle;
      import javafx.application.Platform;
      import javafx.fxml.FXML;
      import javafx.fxml.Initializable;
      import javafx.scene.Node;
      import javafx.scene.control.Alert;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.TextField;
      import javafx.scene.input.MouseEvent;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;
      public class LoginController implements Initializable {
      private Main Main;
      @FXML
      private TextField Username;
      @FXML
      private TextField Password;
      @Override
      public void initialize(URL url, ResourceBundle rb) {
      }
      public void setMain(Main Main) {
      this.Main = Main;
      }
      @FXML
      private void actionLogin(MouseEvent event) throws IOException, Exception {
      if(Username.getText().trim().equals("")&&Password.getText().trim().equals("")){

      Alert alert = new Alert(Alert.AlertType.INFORMATION);
      alert.setHeaderText(" Informasi Login");
      alert.setContentText(" Isian Nama dan Password masih kosong
      "
      + " Silahkan diisi terlebih dahulu");
      alert.showAndWait();

      Username.requestFocus();
      }else if(Username.getText("User")&&Password.getText().trim().equals("qwerty")){
      Node node = (Node) event.getSource();
      Stage dialogStage_1 = (Stage) node.getScene().getWindow();
      dialogStage_1.close();

      Main.showMainMenu();
      }else {
      Alert alert = new Alert(Alert.AlertType.WARNING);
      alert.setHeaderText(" Informasi Login");
      alert.setContentText("Nama dan Password Salah,
      "
      + " Silahkan diulangi");
      alert.showAndWait();
      Username.requestFocus();
      }catch (ClassNotFoundException cnf){
      cnf.printStackTrace();
      }catch (SQLException se){
      se.printStackTrace();
      }
      }

    • @donykisworo6709
      @donykisworo6709 8 років тому

      I've posted his code. How? Whether JavaFX is prolematic when 3 fxml?

  • @albukrek
    @albukrek 7 років тому

    Thank You very useful for me