?1
public
?
class
?CmdSplash?
{
?2
????
/**?*/
/**
?3
?????*?
@param
?str
?4
?????
*/
?5
????
public
?
static
?
void
?main(String[]?str)?
{
?6
????????System.out.println(
"
test
"
);
?7
????}
?8
?9
}
10



?2


?3

?4

?5



?6

?7

?8

?9

10

?1
import
?org.eclipse.swt.SWT;
?2
import
?org.eclipse.swt.widgets.Display;
?3
import
?org.eclipse.swt.widgets.Shell;
?4
?5
?6
public
?
class
?SwtSplash?
extends
?Shell?
{
?7
?8
????
/**?*/
/**
?9
?????*?Launch?the?application
10
?????*?
@param
?args
11
?????
*/
12
????
public
?
static
?
void
?main(String?args[])?
{
13
????????
try
?
{
14
????????????Display?display?
=
?Display.getDefault();
15
????????????SwtSplash?shell?
=
?
new
?SwtSplash(display,?SWT.SHELL_TRIM);
16
????????????shell.open();
17
????????????shell.layout();
18
????????????
while
?(
!
shell.isDisposed())?
{
19
????????????????
if
?(
!
display.readAndDispatch())
20
????????????????????display.sleep();
21
????????????}
22
????????}
?
catch
?(Exception?e)?
{
23
????????????e.printStackTrace();
24
????????}
25
????}
26
27
????
/**?*/
/**
28
?????*?Create?the?shell
29
?????*?
@param
?display
30
?????*?
@param
?style
31
?????
*/
32
????
public
?SwtSplash(Display?display,?
int
?style)?
{
33
????????
super
(display,?style);
34
????????createContents();
35
????}
36
37
????
/**?*/
/**
38
?????*?Create?contents?of?the?window
39
?????
*/
40
????
protected
?
void
?createContents()?
{
41
????????setText(
"
SWT?Application
"
);
42
????????setSize(
500
,?
375
);
43
????????
//
44
????}
45
46
????@Override
47
????
protected
?
void
?checkSubclass()?
{
48
????????
//
?Disable?the?check?that?prevents?subclassing?of?SWT?components
49
????}
50
51
}
52

?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

按照上面幾篇文章的方法測試這兩個“骨頭程序”,可以看到命令行程序和SWT程序同樣可以享受到JAVA6帶來的Splash