This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why

 
sae0203
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
Emil Karlsson
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
/Emil
 
sae0203
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mm... so that's why. thanks emil
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic