views:

33

answers:

1

I want to create a listener that works like mouselistener, but it must be a component: F.e. i have two JComponents (One is a button, and second is MyComponent), and i want to do following:

button.addMyComponentListener(listener); And if MyComponent for example has moved above button, it must fires an event, or if MyComponent has change some propertyw when he is above button, it must be also an event.

+1  A: 

A MouseListener is a kind of EventListener and every JComponent contains an EventListenerList. You can use the approach outlined in EventListenerList to enable your custom JComponent subclass to fire your custom event.

trashgod