Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton Array  RSS feed

 
Pratik Khetia
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
I am having the following problem.
I want to diplay no of button in a window (using GridLayout) but the no of buttons I want to create is coming from an argument. for e.g. if the arg = 50 I want to create 50 different Jbuttons.
So if anyone has any idea..Please help me...

thanks
Pratik
 
ravindran shanmugam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public static void main(String args[])
{
JButton jb[] = new JButton[Integer.parseInt(args[0])];
jb[0] = new JButton("df");
jb[1] = new JButton("dfsd");
// and then add it to the required frame
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!