import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class app {
jframe frame;
jwindow splash;
public app(graphicsconfiguration gc) {
frame = new jframe("app", gc);
createsplash();
swingutilities.invokelater(new runnable() {
public void run() {
showsplash();
splash.repaint();
}
});
initframe();
swingutilities.invokelater(new runnable() {
public void run() {
showframe();
hidesplash();
}
});
}
private void createsplash() {
splash = new jwindow(frame);
splash.getcontentpane().add(new jlabel(new imageicon("images/splash.jpg")));
splash.pack();
rectangle rec = frame.getgraphicsconfiguration().getbounds();
splash.setlocation(rec.x + rec.width/2 - splash.getsize().width/2,
rec.y + rec.height/2 - splash.getsize().height/2);
}
private void showsplash() {
splash.show();
}
private void hidesplash() {
splash.setvisible(false);
splash = null;
}
private void initframe() {
// some code here
}
private void showframe() {
frame.pack();
frame.setvisible(true);
frame.repaint();
}
public static void main(string[] args) {
new app(graphicsenvironment.getlocalgraphicsenvironment().getdefaultscreendevice().getdefaultconfiguration());
}
}