Question

I'm using NetBeans IDE 6.8 (Mac Version). which tool of their GUI builder will assist me in doing this?

What I want is is to show the user an image while my application is loading for couple of seconds before I show him the application. How can I do that? initializing

Was it helpful?

Solution

If you have Java 6 installed, checkout the Splash-Screen tutorial.

OTHER TIPS

actually, you can do that by using the -splash flag in the java program... for example, you want to show the image splash.jpg when you run main.class,

so what you will do is,

java -splash:pathoftheimage/splash.jpg main

As you're running on a MAC you probably won't have access to Java 6 and so will have to build the splashscreen yourself. You should run code similar to the following early in your initialisation cycle (i.e. so that the splashscreen dialog is displayed for the maximum amount of time).

JDialog dlg = new JDialog();
// Remove dialog decorations to make it look like a splashscreen.
dlg.setUndecorated(true);
dlg.setModal(true);
dlg.setLayout(new BorderLayout());
// Load image.
ImageIcon img = new ImageIcon(getClass().getResource("/foo/bar/splash.png");
// Add image to center of dialog.
dlg.add(img, BorderLayout.CENTER);
dlg.setLocationRelativeTo(null);
dlg.setVisible(true);

// ... Perform application initialisation here.

// Initialisation complete so hide dialog.
dlg.setVisible(false);
dlg = null;

If you are using NetBeans... then don't worry NetBeans has solved this problem for you.

  1. Right Click On your Project after opening it.
  2. Go to properties
  3. Click Application
  4. There will be Splash Screen, Browse your image which you want to show.

As shown in Pictures below

enter image description here

enter image description here

When you will do this , your image will show but you will not be able to see this. To See it, you have to delay time of appearence of next window. For this do these steps.

  1. Go to your JFrame code area which you want to show next.
  2. In Main Fun there will be run fun.
  3. Inside run function just write the following code.

    try{

    Thread.sleep(time in milisecond just like 4200);

    //Create Next Frame Object Here }

    catch(Exception ex) { }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top