Question

If I have 5 JPanels with the same mouse adapter and I would like to determine which panel was clicked, how would I do that?

Was it helpful?

Solution

MouseEvent is a subclass of ComponentEvent, so:

http://download.oracle.com/javase/6/docs/api/java/awt/event/ComponentEvent.html#getComponent%28%29

getComponent

public Component getComponent()

Returns the originator of the event.

Returns: the Component object that originated the event, or null if the object is not a Component.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top