-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExam8.java
More file actions
55 lines (46 loc) · 1.48 KB
/
Copy pathExam8.java
File metadata and controls
55 lines (46 loc) · 1.48 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
53
54
55
import javax.swing.*;
import java.awt.*;
public class Exam8 extends JFrame {
public Exam8() {
setTitle("여러 개의 패널을 가진 프레임");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
JPanel pn = new JPanel();
JPanel pc = new JPanel();
JPanel ps = new JPanel();
pc.setLayout(null);
c.add(pn, BorderLayout.NORTH);
c.add(pc);
c.add(ps, BorderLayout.SOUTH);
for (int i=0; i<4; i++) {
JButton btn = new JButton();
String[] str = {"열기", "닫기", "나가기", "Word Input"};
btn.setText(str[i]);
if(i<3) {
pn.add(btn);
} else {
ps.add(btn);
}
}
pn.setBackground(Color.GRAY);
ps.setBackground(Color.YELLOW);
JTextField stf = new JTextField(10);
ps.add(stf);
for(int i=0; i<10; i++) {
int x = (int)(Math.random()*200)+10;
int y = (int)(Math.random()*200)+10;
JLabel la = new JLabel("*");
la.setForeground(Color.RED);
la.setLocation(x,y);
la.setSize(30,30);
pc.setOpaque(true);
pc.add(la);
}
setSize(400,400);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Exam8();
}
}