splash,闪屏,说白了了就是启动广告,许多正规软件或者说许多软件为了显示自己正规,在启动的时候都要来这么一下。明明自己程序启动慢,怕用户启动以后半天看不到东西而产生不满、怀疑或鄙视,为了转移矛盾而弄出这么个讨厌的东西。对于splash偶一向除之而后快,比如加-nosplash,直接删掉splash文件等等。
但是今天偶还是要和大家一起来看看java6里面怎么为自己的程序加上splash,鄙视一下自己先。
准备一个图片,比如Splash.gif
cmd到项目路径下
java -splash:splash.gif HelloSplash
OK,虚拟机启动之后,对话框启动之前就会看到你准备的图片。
但是今天偶还是要和大家一起来看看java6里面怎么为自己的程序加上splash,鄙视一下自己先。
1
import java.awt.BorderLayout;
2
import javax.swing.JFrame;
3
import javax.swing.JLabel;
4
5
6
public class HelloSplash extends JFrame
{
7
8
/** *//**
9
* Launch the application
10
* @param args
11
*/
12
public static void main(String args[])
{
13
try
{
14
HelloSplash frame = new HelloSplash();
15
frame.setVisible(true);
16
} catch (Exception e)
{
17
e.printStackTrace();
18
}
19
}
20
21
/** *//**
22
* Create the frame
23
*/
24
public HelloSplash()
{
25
super();
26
getContentPane().setLayout(null);
27
setBounds(100, 100, 500, 375);
28
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
29
30
final JLabel label = new JLabel();
31
label.setBounds(69, 49, 275, 102);
32
label.setText("测试splash");
33
getContentPane().add(label);
34
//
35
}
36
37
}
38

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

准备一个图片,比如Splash.gif
cmd到项目路径下
java -splash:splash.gif HelloSplash
OK,虚拟机启动之后,对话框启动之前就会看到你准备的图片。