|
||||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
---|---|
paxoftwer.forms |
This splash screen package allows to display an image picture during some initialization processes on the application's startup. After the instanciation of the SplashScreen class it starts showing of the picture.
You can pass following values to the constructor:
Time value in milli-seconds: This parameter determines the minimum of time the splash screen will be shown.
In other words, if you passed 3000 milli-seconds (T2), but your application does only need 1500 milli-seconds (T1) for initializing of resources, the splash screen will anyway remain the last 1500 milli-seconds (T delta) until the total remaining time of 3000 (T2) has expired (see drawing).
You can say:
If |T2 - T1| ≠ 0 then
If T2 > T1 then
"Splash screen's total remaining time: T2 milliseconds."Else
"Splash screen's total remaining time: T1 milliseconds."ImageIcon object:
This refers to the class: javax.swing.ImageIcon
For example, you can get one picture file from your application resource path and assign it to such object:
ImageIcon pic = new ImageIcon(SplashScreen.class.getResource("graphics/ani01.gif"));
After doing this, you just pass pic
to SplashScreen
's constructor.
Loading progress indicator:
This may be a proper Swing/AWT component to show continiously concrete loading progress of any resources. Later you can access it via
getProgressComponent()
to change its appearance. Imaginable components are JProgressBar
, JLabel
etc.
Caution: In all cases, you have to position the component by setting the bounds with help of Component.setBounds(int, int, int, int)
.
javax.swing.ImageIcon
.SplashScreen
and pass all necessary values to the constructor. This step should
be the first thing what your application is doing at startup, because the splash screen will be directly shown after its instanciation.SplashScreen
object the termination signal. If you don't do it, it won't fade away.JSplashScreen
with a simple GIF animation file and starts showing it for at least 3 seconds.
Furthermore, we are adding a JProgressBar, inclusively refreshing its progress state during the simulated computing process. The computing
process equals a simple Thread.sleep(long)
and lasts for 6 seconds (3 seconds more than the minimum showing time). The expected
behaviour of the splash screen is to remain for 6 seconds:
public static void main(String args[]) throws InterruptedException
{
long start = System.currentTimeMillis(), length = 6000;
ImageIcon pic = new ImageIcon(JSplashScreen.class.getResource("graphics/ani01.gif"));
JProgressBar prog = new JProgressBar();
prog.setSize(pic.getIconWidth() - 2, 14);
prog.setStringPainted(true);
prog.setBounds(1, pic.getIconHeight() - prog.getHeight() - 1, prog.getWidth(), prog.getHeight());
JSplashScreen splash = new JSplashScreen(3000, pic, prog);
do
{
Thread.sleep(1);
prog.setString(((System.currentTimeMillis() - start) * 100 / length)
+ "% loaded...");
((JProgressBar) splash.getProgressComponent()).setValue((int) ((System.currentTimeMillis() - start) * 100 / length));
} while (System.currentTimeMillis() - start < length);
splash.killSplashScreen();
}
Preview:
|
||||||||||
PREV NEXT | FRAMES NO FRAMES |