Reputation: 5959
My code has a JPanel that contains a JTextPane that covers most of the JPanel. I would like to detect a mouse click if the event occurs anywhere in the panel, but the JTextPane blocks the event, unless I register a listener to it. Is there some easy way to observe the event without adding in listeners for every child?
Upvotes: 3
Views: 2854
Reputation: 324118
You can use a Global Event Listener to listen for the mouse events.
You can use:
SwingUtilities.isDescendingFrom(...);
to help determine if the component that generated the event is a child of the panel.
Upvotes: 7