hi am using JavaFx i want to create a simple window that will appear at first the application will go start then it will stay for short time then it will disappear automatically without any event then my main window will appear now can anyone help me in this idea
Asked
Active
Viewed 785 times
1
-
Please post some code you have tried, and explain why it doesn't do what you want. You also need to clarify your question (a lot). What do you mean by a "short time"? How long? Why do you want to do this: are you creating a splash screen while data loads? – James_D Oct 02 '15 at 14:42
-
i meant several seconds appear i will specefic the time,i want to do this cuz i have a simple idea to make a presentation for my app,such as photoshop when it begin starting the first window appear about them logo and etc. such as window for display welcome – Fadi Fodoy Oct 02 '15 at 14:58
-
It looks like you want something like [preloader](http://docs.oracle.com/javafx/2/deployment/preloaders.htm), that does nothing except showing up for a set period of time. – Manik Oct 02 '15 at 15:31
-
Usually a splash screen, which is what you are describing, serves a purpose: it is displayed while startup processes are happening in the background. If you don't have any startup processes, you should not use a splash screen (it is an unnecessary delay). If you do have startup processes, your question is much more complex. Again, please show your existing code. – James_D Oct 02 '15 at 15:56
-
Maybe see the answer to this (seemingly?) related question: [How to use javaFX Preloader with stand-alone application in Eclipse?](http://stackoverflow.com/questions/15126210/how-to-use-javafx-preloader-with-stand-alone-application-in-eclipse). Even though the question talks about pre loaders, there are other ways mentioned in the answer to achieve similar functionality (e.g. just creating a JavaFX stage like [this sample](https://gist.github.com/jewelsea/2305098)), or by using the `-splash:
` command line switch. – jewelsea Oct 02 '15 at 18:35 -
am beginner in javafx and in stackOverFlow but am i don't need to do any proesses in background it is just logo for example " welcome to this app" – Fadi Fodoy Oct 02 '15 at 22:28
-
when am run my app ... i want to pop up the window that hold this statment " welcome" for 5 second then it will hide and go to my main window(scene) am using Fxml application nd scene builder – Fadi Fodoy Oct 02 '15 at 22:33
-
We provided you links to research. Custom stages and preloaders can do the job even though it will delay startup without any reason. Show us your code/research. What did you try? – Manik Oct 03 '15 at 00:23
1 Answers
1
package x;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class AutoHideExmpl extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
VBox v = new VBox();
TextField fiiled = new TextField("asdasdf");
TextField d = new TextField("asdfasdf");
TextField gd = new TextField("asdf");
TextField da = new TextField("asdf");
TextField cd = new TextField("asdf");
v.getChildren().addAll(fiiled, d, gd, da, cd);
v.setMinSize(500, 500);
Scene c = new Scene(v);
primaryStage.setScene(c);
primaryStage.show();
Stage s1 = new Stage();
VBox v1 = new VBox();
TextField fiiled1 = new TextField("asdasdf");
TextField d1 = new TextField("asdfasdf");
TextField gd1 = new TextField("asdf");
TextField da1 = new TextField("asdf");
TextField cd1 = new TextField("asdf");
v1.getChildren().addAll(fiiled1, d1, gd1, da1, cd1);
v1.setMinSize(300, 300);
Scene c1 = new Scene(v1);
s1.setScene(c1);
s1.show();
Task t = new Task<Void>() {
@Override
protected Void call() throws Exception {
Thread.sleep(60000);
Platform.runLater(() -> {
s1.close();
});
System.out.println("hidding");
return null;
}
};
Thread ts = new Thread(t);
ts.start();
}
}
you can user this too
Thread ts = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(60000);
Platform.runLater(() -> {
s1.close();
});
System.out.println("hidding");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
ts.start();
i hope this will help you if any ? write comment

Gaali Prabhakar
- 583
- 6
- 23
-
- @Fadi Fodoy is above ans is use full ? if not tel me .i ll add a image in startup window and I ll re post my code – Gaali Prabhakar Oct 04 '15 at 20:27