<p>I was wondering if there is a way to implement an action listener for a Jbutton without a name. For example, I have the following for loop that creates a button for each letter of the alphabet.</p>

<pre><code>for (int i = 65; i &lt; 91; i++){
     alphabetPanel.add(new JButton("&lt;html&gt;&lt;center&gt;" + (char)i));
}
</code></pre>

<p>Is there a way that I can add an action listener for each of those buttons without getting rid of my for loop and hard coding each JButton and then creating an action listener for each? </p>

<p>Thanks in advance,</p>

<p>Tomek</p>

Your question is a little vague.  it would be trivial to modify the loop to add a listener inside the loop:
```
```
ActionListener listener = something;

for (int i = 65; i < 91; i++){
     JButton button = new JButton("<html><center>" + (char)i);
     button.addActionListener( listener );
     alphabetPanel.add(button);
}
```
```
if you can't modify the loop you could iterate over all of the panel's children, and add listeners to any of the children that are jbuttons.
also why are you using html to center the text?  isn't that overkill? doesn't jbutton already center text?
you could use setHorizontalAlignement(SwingConstants.CENTER) to do it too.