lotus03
asked on
How to display Splash Screen in longer time?
How to display a splash screen in a longer time? such as in 10 seconds time.... Thank you!
Code:
************************** *******
public static void main( String[] args )
{
String baseDir="";
if(args.length>0){ baseDir=args[0]; }
splashScreen = new SplashScreen(10);
splashScreen.dispose();
Bella bella= new bella();
}
Code:
**************************
public static void main( String[] args )
{
String baseDir="";
if(args.length>0){ baseDir=args[0]; }
splashScreen = new SplashScreen(10);
splashScreen.dispose();
Bella bella= new bella();
}
http://www.javaworld.com/javaworld/javatips/jw-javatip104.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Pretty Fast Guys;
Here are my share :
class SplashWindow3 extends JWindow
{
public SplashWindow3(String filename, Frame f, int waitTime)
{
super(f);
JLabel l = new JLabel(new ImageIcon(filename));
getContentPane().add(l, BorderLayout.CENTER);
pack();
Dimension screenSize =
Toolkit.getDefaultToolkit( ).getScree nSize();
Dimension labelSize = l.getPreferredSize();
setLocation(screenSize.wid th/2 - (labelSize.width/2),
screenSize.height/2 - (labelSize.height/2));
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
setVisible(false);
dispose();
}
});
final int pause = waitTime;
final Runnable closerRunner = new Runnable()
{
public void run()
{
setVisible(false);
dispose();
}
};
Runnable waitRunner = new Runnable()
{
public void run()
{
try
{
Thread.sleep(pause);
SwingUtilities.invokeAndWa it(closerR unner);
}
catch(Exception e)
{
e.printStackTrace();
// can catch InvocationTargetException
// can catch InterruptedException
}
}
};
setVisible(true);
Thread splashThread = new Thread(waitRunner, "SplashThread");
splashThread.start();
}
}
Here are my share :
class SplashWindow3 extends JWindow
{
public SplashWindow3(String filename, Frame f, int waitTime)
{
super(f);
JLabel l = new JLabel(new ImageIcon(filename));
getContentPane().add(l, BorderLayout.CENTER);
pack();
Dimension screenSize =
Toolkit.getDefaultToolkit(
Dimension labelSize = l.getPreferredSize();
setLocation(screenSize.wid
screenSize.height/2 - (labelSize.height/2));
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
setVisible(false);
dispose();
}
});
final int pause = waitTime;
final Runnable closerRunner = new Runnable()
{
public void run()
{
setVisible(false);
dispose();
}
};
Runnable waitRunner = new Runnable()
{
public void run()
{
try
{
Thread.sleep(pause);
SwingUtilities.invokeAndWa
}
catch(Exception e)
{
e.printStackTrace();
// can catch InvocationTargetException
// can catch InterruptedException
}
}
};
setVisible(true);
Thread splashThread = new Thread(waitRunner, "SplashThread");
splashThread.start();
}
}
>> Thread.sleep(pause);
Give a interval something like 1000
Hope it helps . . .
Javatm
Give a interval something like 1000
Hope it helps . . .
Javatm
Javatm, you copied from the article that I gave!
I dont think so, I've researched it here on EE,
before you post it I already seen it. So I added it.
Sorry if I paste it friend :)
before you post it I already seen it. So I added it.
Sorry if I paste it friend :)
Here is a proof from objects answer :
https://www.experts-exchange.com/questions/20422116/Splash-Screen.html
https://www.experts-exchange.com/questions/20422116/Splash-Screen.html