aspose file tools*
The moose likes Java in General and the fly likes Loop adding Listeners to objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Loop adding Listeners to objects" Watch "Loop adding Listeners to objects" New topic
Author

Loop adding Listeners to objects

Tom Josephits
Greenhorn

Joined: Mar 11, 2012
Posts: 28
I'm working on a game where there are 9 grids all in one larger grid. I had a few rather complex ideas before realizing I could simplify it by making each grid it's own. Anyway, I needed each grid to listen for it being clicked on. I need it to be able to identify which grid it is specifically so I thought the easiest way to do that would be to loop through the children of the main grid and add a listener to each. But, for some reason the listener only works for one of them. And on top of that, it's the second one. It's a bit hard to give a full functional version of the code because it's a bit at the point where everything is pretty strongly interconnected but here's an example:


Everything works except for the listener
Tom Josephits
Greenhorn

Joined: Mar 11, 2012
Posts: 28
Never mind. I'm a moron. I left a bit in the loop that I forgot to change when I was switching things around.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36452
    
  15
Tom Josephits wrote:Never mind. I'm a moron. . . .
No, you aren’t. You just needed a bit of rubber‑ducking.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loop adding Listeners to objects
 
Similar Threads
Java Code
Battleships - guys please help me out!
Is their a GUI app that can slice, dice ,and resassemble a JPG image on the screen?
How to group these JLabels?
Accordion Widget