File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes why Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "why" Watch "why" New topic


Ranch Hand

Joined: Sep 19, 2002
Posts: 34
why can't i add this in the container like this?

label1 = new JLabel("Type");
label2 = new JLabel("Product ID");
label3 = new JLabel("Stock Available");
label4 = new JLabel("Quantity Needed");
label5 = new JLabel("Estimated Buy In");
label6 = new JLabel("Needed By");
label7 = new JLabel("Total Cost");

pan5.add(label1, label2, label3, label4, label5, label6, label7);

txt1=new JTextField("",5);
txt2=new JTextField("",5);
txt3=new JTextField("",5);
txt4=new JTextField("",5);
txt5=new JTextField("",5);
txt6=new JTextField("",5);
txt7=new JTextField("",5);

pan4.add(txt1, txt2, txt3, txt4, txt5, txt6, txt7);

SAE <br /> <br /><a href="" target="_blank" rel="nofollow"></a>
Emil Karlsson
Ranch Hand

Joined: May 23, 2002
Posts: 63
Hi, ambrosia
If you take a look att the add() method in Container you wil see that it can only take one component each time you use it.
add(Component comp)
add(Component comp, int index)
add(Component comp, Object constraints)
add(Component comp, Object constraints, int index)
add(String name, Component comp)
But there are some other things that is possible to include.
Ranch Hand

Joined: Sep 19, 2002
Posts: 34
mm... so that's why. thanks emil
I agree. Here's the link:
subject: why
jQuery in Action, 3rd edition