반응형
BorderLayout 안에 BorderLayout 을 넣어본다
거두절미 소스투척
|
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
56
57
58
59
60
61
62
63
64
65
66
67
|
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ExTestLayout {
// 컴포넌트 생성
JFrame jFrame = new JFrame("BorderLayout in BorderLayout");
JButton btn1 = new JButton("1번버튼");
JButton btn2 = new JButton("2번버튼");
JButton btn3 = new JButton("3번버튼");
JButton btn4 = new JButton("4번버튼");
JButton btn5 = new JButton("5번버튼");
JButton btn01 = new JButton("01");
JButton btn02 = new JButton("02");
JButton btn03 = new JButton("03");
JButton btn04 = new JButton("04");
JButton btn05 = new JButton("05");
public ExTestLayout() {
// 컴포넌트를 넣을 컨테이너 구하기
Container container = jFrame.getContentPane();
// 컴포넌트를 컨테이너에 추가
container.add(btn1, BorderLayout.NORTH);
container.add(btn2, BorderLayout.EAST);
JPanel panel = new JPanel();
panel.add(btn01);
panel.add(btn02);
panel.add(btn05);
panel.add(btn03);
panel.add(btn04);
BorderLayout borderLayout = new BorderLayout();
borderLayout.addLayoutComponent(btn01, BorderLayout.NORTH);
borderLayout.addLayoutComponent(btn02, BorderLayout.EAST);
borderLayout.addLayoutComponent(btn05, BorderLayout.CENTER);
borderLayout.addLayoutComponent(btn03, BorderLayout.WEST);
borderLayout.addLayoutComponent(btn04, BorderLayout.SOUTH);
panel.setLayout(borderLayout);
container.add(panel, BorderLayout.CENTER);
container.add(btn3, BorderLayout.WEST);
container.add(btn4, BorderLayout.SOUTH);
// 프레임 크기 지정
jFrame.setSize(600, 300);
// 프레임 보이기 설정
jFrame.setVisible(true);
// 종료 버튼 설정
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
// 실행
new ExTestLayout();
}
}
|
cs |
나중에 내가 다시 봤을때 뭔지 이해 안가거나 누군가 지적해준다면 좀더 간결하게 고쳐볼 마음이 있다
반응형
'개발 실무' 카테고리의 다른 글
| [JAVA][SWING]Button Table Example : Grid Table (0) | 2018.09.13 |
|---|---|
| [JAVA][SWING]setBorder TitledBorder LineBorder (0) | 2018.09.13 |
| [JAVA][SWING]ActionListener 사용설명서 (0) | 2018.09.12 |
| [JAVA][eclipse][ERROR] eclipse PHOTON 설치 오류 (1) | 2018.09.11 |
| 진행바,프로그레스바(JProgressBar) (5) | 2018.09.11 |