01.
package
com.java.myapp;
02.
03.
import
java.awt.EventQueue;
04.
import
javax.swing.ImageIcon;
05.
import
javax.swing.JFrame;
06.
import
javax.swing.JLabel;
07.
08.
09.
public
class
MyForm
extends
JFrame {
10.
11.
12.
13.
14.
public
static
void
main(String[] args) {
15.
EventQueue.invokeLater(
new
Runnable() {
16.
public
void
run() {
17.
MyForm frame =
new
MyForm();
18.
frame.setVisible(
true
);
19.
}
20.
});
21.
}
22.
23.
24.
25.
26.
public
MyForm() {
27.
28.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
29.
setBounds(
100
,
100
,
362
,
249
);
30.
setTitle(
"ThaiCreate.Com Java GUI Tutorial"
);
31.
getContentPane().setLayout(
null
);
32.
33.
34.
JLabel label1 =
new
JLabel(
"Welcome to.."
);
35.
label1.setBounds(
130
,
49
,
99
,
14
);
36.
getContentPane().add(label1);
37.
38.
39.
JLabel label2 =
new
JLabel();
40.
label2.setText(
"ThaiCreate.Com"
);
41.
label2.setBounds(
111
,
74
,
128
,
14
);
42.
label2.setHorizontalTextPosition(JLabel.CENTER);
43.
getContentPane().add(label2);
44.
45.
46.
JLabel lbl3 =
new
JLabel(
new
ImageIcon(getClass().getResource(
"save.gif"
)));
47.
lbl3.setBounds(
142
,
119
,
46
,
14
);
48.
getContentPane().add(lbl3);
49.
50.
}
51.
52.
}