IntelliJ Java IDE
The moose likes Swing / AWT / SWT / JFace and the fly likes JButton Array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "JButton Array" Watch "JButton Array" New topic
Author

JButton Array

Pratik Khetia
Ranch Hand

Joined: Jun 29, 2001
Posts: 50
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

Joined: Aug 30, 2001
Posts: 15
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
}
 
 
subject: JButton Array
 
Threads others viewed
Using a String variable as an object name in a loop...Possible??
Math.random()
Eclipse - include default header
Dynamic table selects
Scrollable result sets and physical reads...
Two Laptop Bag