-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava216_gui.java
More file actions
50 lines (39 loc) · 1.1 KB
/
Copy pathJava216_gui.java
File metadata and controls
50 lines (39 loc) · 1.1 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
package java0915_gui;
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
class UserLayout extends Frame {
Button northBtn, centerBtn, southBtn, eastBtn, westBtn;
public UserLayout() {
northBtn = new Button("north");
centerBtn = new Button("center");
southBtn = new Button("south");
eastBtn = new Button("east");
westBtn = new Button("west");
setLayout(new GridLayout(2, 3));
this.add(northBtn);
this.add(centerBtn);
this.add(southBtn);
this.add(eastBtn);
this.add(westBtn);
northBtn.setForeground(new Color(0, 255, 0)); // RGB값 0~255
northBtn.setBackground(new Color(255, 0, 0)); // RED GREEN BLUE
setBackground(Color.cyan); // 색깔 상수는 대소문자구별을 하지 않는다.
setSize(500, 400);
setVisible(true);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
public class Java216_gui {
public static void main(String[] args) {
new UserLayout();
}
}