0
제 japanel에는 2 열 너비의 componetet이 있습니다. 하단에이 2 개의 열을 초과하지 않는 4 개의 단추를 추가하고 싶습니다. 그러나, 내가 얻는 것은 4 개의 모든 단추가 4 개의 열을 가로 질러 뻗어 있고, 2 개의 clumns를 초과합니다. cancelButton에는 이상한 수평 연장이 있습니다.Java Swing : GridBagLayout, 4 개의 버튼을 2 개의 열로 압착하는 방법은 무엇입니까?
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbl.setConstraints(someComponenetHere, gbc);
gbc.gridy = 2;
gbl.setConstraints(applyButton, gbc);
gbc.gridx = 1;
gbc.gridy = 2;
gbc.gridwidth = 1;
gbl.setConstraints(cancelButton, gbc);
gbc.gridx = 2;
gbc.gridy = 2;
gbc.gridwidth = 1;
gbl.setConstraints(applyAddButton, gbc);
gbc.gridx = 3;
gbc.gridy = 2;
gbc.gridwidth = 1;
gbl.setConstraints(applyAddAllButton, gbc);
그러면 모든 것이 더 넓어지게되는 4 개의 열이됩니다. – KJW
레이아웃 관리자가 사용하려는 열 개수와 독립적으로 패널 크기를 제어 할 수 있습니다. – John3136
그래, 내가 해냈어. – KJW