Re: adding a List of JTextField to the GUI



thufir wrote:

here's what I have:

If all you need right now is just to get some labels and text fields displayed, you could do it by adding a label and a text field to one panel, then just stack the panels on top of each other. That's not nearly as sophisticated as what the GroupLayout will let you do, but it'll get you a working JFrame.

class TestApp extends JFrame {

TestApp() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
add(panel);
for (int i = 1; i <= 4; i++) {
JPanel nuPanel = new JPanel();
nuPanel.add(new JLabel("Label " + i));
nuPanel.add(new JTextField(i * 4));
panel.add(nuPanel);
}
pack();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
}

public static void main(String[] args) {
new TestApp().setVisible(true);
}
}
.