File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes an array of buttons in an applet ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "an array of buttons in an applet ?" Watch "an array of buttons in an applet ?" New topic
Author

an array of buttons in an applet ?

Aaron Harp
Greenhorn

Joined: Jul 12, 2006
Posts: 8
I have the following code and I know there must be a way to simplify it, I just don't know enough about Java to know how. Is there any way that you could create an array of buttons? That way I could just use a for loop to set their values, position, and create them. Thanks in advance!

Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Yes, you can create an array of any type in Java.
Aaron Harp
Greenhorn

Joined: Jul 12, 2006
Posts: 8
Would I just use

Button buttons[];

?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Aaron Harp:
Would I just use

Button buttons[];

?


Button[] buttons is another way. You'll find this technique neat when you are just creating a GUI with no real workings. But once you need all those buttons to actually do something, the technique won't really work anymore. Well, unless all the buttons do the same thing.


GenRocket - Experts at Building Test Data
Aaron Harp
Greenhorn

Joined: Jul 12, 2006
Posts: 8
If all the buttons are in an array you can use a for loop in the actionPerformed method as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: an array of buttons in an applet ?