제 폼에서 SpringLayout을 사용 합니다만, 보시다시피 모양이 좋지 않습니다 (크기가 크고 크기가 큽니다)!SpringLayout의 컴포넌트 크기
public class t8 extends JFrame {
JButton okButton, cancellButton;
JTextField idTF, nameTf;
JLabel idlbl, namelbl;
public t8() {
add(createPanel(), BorderLayout.CENTER);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 500);
setLocation(400, 100);
setVisible(true);
}
public static void main(String[] args) {
new t8();
}
public JPanel createPanel() {
JPanel panel = new JPanel();
okButton = new JButton("Ok");
cancellButton = new JButton("Cancel");
idTF = new JTextField(10);
nameTf = new JTextField(10);
idlbl = new JLabel("ID");
namelbl = new JLabel("Name");
panel.add(idlbl);
panel.add(idTF);
panel.add(namelbl);
panel.add(nameTf);
panel.add(okButton);
panel.add(cancellButton);
panel.setLayout(new SpringLayout());
SpringUtilities.makeCompactGrid(panel, 3, 2, 20, 50, 50, 100);
return panel;
}
}
나는 makeCompactGrid
번호를 변경, 그러나 성공하지 않았다!
(JTextFields
의 폭이 크고, 내 버튼의 크기가 다른) 내가 넷빈즈 드래그를 사용하여 물리적 구성 요소를 설정 할 수 있도록 도구를 드롭을 제안하고 또한 당신에게 줄 것이다
'GourpLayout'이 보이겠습니까? [here] (http://stackoverflow.com/a/8504753/230513), 대안이 될까요? – trashgod
+1 @aterai에 의해 [한 발 차기] (http://stackoverflow.com/a/16602249/714968) 참조, 비율은 GridBagLayout (매우 비슷한 또는 앵커와 함께)으로 설정할 수 있으며 나머지 아이디어는 구현됩니다. in MigLayout – mKorbel
@mKorbel 좋은 도움 – Sajad