-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava214_gui.java
More file actions
52 lines (41 loc) · 1.16 KB
/
Copy pathJava214_gui.java
File metadata and controls
52 lines (41 loc) · 1.16 KB
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
package java0915_gui;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
class FlowLayoutTest extends Frame {
Button oneBtn, twoBtn, threeBtn;
Panel pn;
TextArea ta;
public FlowLayoutTest() {
oneBtn = new Button("one");
twoBtn = new Button("two");
threeBtn = new Button("three");
// Panel 의 기본 레이아웃은 FlowLayout이다.
// FlowLayout에 컴포넌트를 연결할 때는 add 해준 순서대로 왼쪽에서부터 오른쪽으로 연결 된다.
pn = new Panel(); // Panel은 Frame과 다르게 혼자서 창을 띄울 수 없다.
pn.add(oneBtn);
pn.add(twoBtn);
pn.add(threeBtn);
ta = new TextArea(10, 20);
this.add(BorderLayout.NORTH, pn);
this.add(BorderLayout.CENTER, ta);
setSize(500, 400);
setVisible(true);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
public class Java214_gui {
public static void main(String[] args) {
new FlowLayoutTest();
}
}