This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm making simple gallery, and i have small problem. I have for List of 20 JButtons (which icon is my Image). I don't want to add MouseListeners to each JButton. And i tried to add Action Listener in a loop. I tried something like this:
and it doesn't work, because button wasn't pressed. licznik (my counter variable) counts from 1 to 20,"while" loop sets action listener for every JButton, but when I click on my JButton it always display last image on the list (number 20).
I think i would have to click the JButton on each iteration. I tried also with something like this:
And it also doesn't work. It makes "clicks", but when I click on any button in my gallery it always displays last image.
Is it possible to add action/mouse listeners in a loop to the List of Components?