How do you make a Component in general catch mouse activity?
When you click the mouse onscreen anywhere in your main window, say MainComponent, you can catch mouse events easily. You just override a mouse callback method such as mouseDown or mouseUp–and do the programming. Correct?
However, when you click on a Component onscreen, say Label, those mouse callback methods do not work! The reason is clear: Components follow their own rules when it comes to mouse activity and other things. But… I wish I can associate Label with common mouse events. It should react like the Rectangle in paint() does.
Now, the MouseListener class provides us with an addMouseListener method. That is the one to use, I guess, in order to accomplish this–but I cannot make it work no matter how hard I try. I tried, for instance, to add this to the constructor
It does not work. Please, help me. Thanks (!)