Below are my code to add label and textfield. i want to add it such that its [label] [textfield] in 2 column
i know i can do it by using gridlayout but the number of rows need to be fixed, hence is there another method to add it such that no matters how many [label] [textfield] i add in, it will be 2 column
the picture shows the expected view
but currently it is [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);
}