Easiest way to overcome Image class does not have a Listener?

Ok I am back after taking a break for 8 months no coding what so ever. So please forgive me if I lost a few billion brain cells in the mean time.

I am continuing working on a synth. I have an Image class that shows current selected waveform but although my waveforms can be selected from a static list, and had it just been so I could certainly use imageButtons, my synth allows unlimited changing and creating new waveforms on the fly, so as a waveform is changed or created I draw (pixel plot using setPixelAt) to the image.

Anyways I would like to be able to click on that image similar to a listener, however to me the Image class does not seem to support a listener.

So what would be the simplest way to overcome this problem? Adding another transparent and blank object on top of the image and then add a listener to that?

I assume you draw the Image into some Component during the Component’s paint() function? In that case, you’d want to implement a mouseDown() (or mouseUp(), if you prefer) in that Component which will respond to the mouse click.

Thanks for replying. Yes it is drawn to inside a Component’s paint() function. I’ll look into that.

You mention that ImageButton won’t work because the images are dynamically created, but could you not just call ImageButton::setImages() with the dynamically created images whenever they change? How often are the images changing?

Sure if I can set an ImageButton’s image from an Image class object, I’ll look into that too, thanks. The images, one per tone generator (oscillator), changes whenever the user edit’s the waveform.