0
GridBagLayout을 사용하려고합니다. 하나의 JLabel이 세로 및 가로로 가운데에 있어야합니다. 간단합니다. GridBagConstraints를 만들지 않아도됩니다. JButton을 오른쪽 아래 모서리에 놓고 싶습니다. 내 중심 패널이 왼쪽으로 이동하거나 버튼이 위로 이동하려고합니다. GridBagLayout 문제
EXPECTING GETTING THIS OR THIS
+-----------+ +-----------+ +-----------+
| | | | | |
| | | | | |
| | | | | |
| +---+ | | +---+ | | +---+ |
| | | | | | | | | | | |
| +---+ | | +---+ | | +---++---+|
| | | | | | ||
| | | | | +---+|
| +---+ | +---+ | |
| | | | | | | |
+-------+---+ +-------+---+ +-----------+
bigPanel = new JPanel();
bigPanel.setPreferredSize(new Dimension(320, 640));
bigPanel.setLayout(new GridBagLayout());
label = new JLabel();
label.setPreferredSize(new Dimension(100,95));
button = new JButton();
button.setPreferredSize(new Dimension(100,25));
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.CENTER;
bigPanel.add(label, c);
c.anchor = GridBagConstraints.LAST_LINE_END;
bigPanel.add(button, c);
는 또한
http://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html 여기에 설명 된 다른 제약 조건을 사용하려고했지만 때마다 뭔가 잘못.