Re: adding a List of JTextField to the GUI



Mark Space wrote:
thufir wrote:

center.add(field); //Why isn't it adding??

center.setLayout(centerLayout);

I'm not sure, but reading your code I'll take a guess. You add the JTextFields to the JPanel's ("center") default FlowLayout, then you toss that away when you set a new layout manager to the new GroupLayout. Hence, the JPanel ends up with no components.

Try setting the layout manager before the for loop.

Or I could be totally wrong. GroupLayout appears to work very differently from most layout managers. You don't add components to the container with add(). You use methods in the GroupLayout to add components and position them.

Better read up:

<http://java.sun.com/docs/books/tutorial/uiswing/layout/group.html>

.



Relevant Pages

  • Re: adding a List of JTextField to the GUI
    ... You add the JTextFields to the JPanel's default FlowLayout, then you toss that away when you set a new layout manager to the new GroupLayout. ...
    (comp.lang.java.help)
  • Interested in a 10 question Java Quiz.
    ... FlowLayout. ... Which layout manager is the default for JFrame? ... d)The JComboBox expands to a list. ...
    (comp.lang.java.programmer)
  • Re: Resizing a JLabel
    ... that is behaviour of FlowLayout. ... I find that the layout manager from JGoodies is much nicer. ... more powerful and can build much faster than GridBagLayout. ... where I use JGoodies LAF and Forms manager is at: ...
    (comp.lang.java.programmer)
  • Re: GUI Tool in NetBeans
    ... The layout manager is called GroupLayout. ... Matisse creates a graphical GUI builder that is based on GroupLayout. ...
    (comp.lang.java.programmer)
  • Re: need help witch an applet
    ... I believe the default layout manager for an applet is the FlowLayout, ... > static Image myImage; ...
    (comp.lang.java.help)