blob: 4ebf637204f372fd1b98e248d7592941912234fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package NET.worlds.console;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
public class SplashScreen extends java.awt.Window {
private static final long serialVersionUID = 4848128412139723543L;
private SplashCanvas sc = null;
public SplashScreen(String appname, String imagename) {
super(new Frame(appname));
this.sc = new SplashCanvas(imagename);
this.add(this.sc);
this.pack();
this.center();
}
public void setImageName(String imagename) {
this.sc.setImage(imagename);
this.pack();
this.center();
this.sc.repaint();
}
public void addOverlay(String name, int x, int y) {
this.sc.addOverlay(name, x, y);
this.center();
}
public void removeOverlay(String name, int x, int y) {
this.sc.removeOverlay(name, x, y);
}
public void center() {
Dimension dim = this.getSize();
Dimension scrdim = Toolkit.getDefaultToolkit().getScreenSize();
int x = scrdim.width >= dim.width ? (scrdim.width - dim.width) / 2 : 0;
int y = scrdim.height >= dim.height ? (scrdim.height - dim.height) / 2 : 0;
this.setLocation(x, y);
}
@Override
public void dispose() {
super.dispose();
try {
this.sc.flush();
} catch (NullPointerException var2) {
System.out.println("Flushing went bad!");
}
}
}
|