Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a JButton array

Status
Not open for further replies.

happyb

Programmer
Oct 25, 2000
29
AU
can I use a JButton array as a parameter in a method used by another class?

I want to bring the JButton array, which happens to have Jbuttons as the values within the array to another class file using addActionListener... but when I try, it won't work... whether I use...

buttons.addActionListener(listener);

or

buttons[].addActionListener(listener);
 
You will have to loop through the array of buttons and add the listeners one-by-one.

JButton[] myButtons = theButtonArrayPassed;

[tt]for (int i=0;i<myButtons.length;i++){
[tab]myButtons.addActionListener.....;
}[/tt]

My Home -->
 
Wow thanks!
It worked!


happyb,
one happy programmer :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top