以下は、ラベルとテキストフィールドを追加する私のコードです。[ラベル] [テキストフィールド] が 2 列になるように追加したい
gridlayoutを使用して実行できることはわかっていますが、行数を固定する必要があるため、追加する[ラベル] [テキストフィールド]の数に関係なく、2列になるように追加する別の方法があります
写真は予想されるビューを示しています
現在は [label] [textfield] [label2] [textfield2] [label3] [textfield3] です。
public WizardPage page1() {
WizardPage page1 = new WizardPage("1", "Page 1") {
{
JTextField txt1 = new JTextField();
JTextField txt2 = new JTextField();
JTextField txt3 = new JTextField();
JTextField txt4 = new JTextField();
txt1.setName("text1");
txt2.setName("text2");
txt3.setName("text3");
txt4.setName("text4");
txt1.setPreferredSize(new Dimension(50, 20));
txt2.setPreferredSize(new Dimension(50, 20));
txt3.setPreferredSize(new Dimension(50, 20));
txt4.setPreferredSize(new Dimension(50, 20));
add(new JLabel("text1"));
add(txt1);
add(new JLabel("text2"));
add(txt2);
add(new JLabel("text3"));
add(txt3);
add(new JLabel("text4"));
add(txt4);
}
};
return page1;
}
> public WizardPage(String title, String description){
>
> PropertyConfigurator.configure("config/log4j.properties");
> log = Logger.getLogger(WizardPage.class);
>
> _title = title;
> _description = description;
>
>
> setLayout(new FlowLayout()); );
addContainerListener(new WPContainerListener());
this.setDoubleBuffered(true);
}