Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem when create many new components  RSS feed

 
Vu Quang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to create many Swing components such as textfields. Example I have to create 10 other textfields .If I create each textfield, I will waste time.
So what are the solution of saving time when create many same components?
Thank U very much!!!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextField[] tf = new JTextField[10];
for(int x = 0; x < tf.length; x++)
{
tf[x] = new JTextField(5);
tf[x].addActionListener(this);
[container].add(tf[x]);
}
 
Vu Quang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank U very much!!!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!