JTabbedPane - MouseEvents on tabs

I'm trying to find some way to add MouseListeners to tabs on a JTabbedPane. I can easily add them, of course, to the components denoted by the tabs, but I need them listening for MouseEvents on the actual buttons that switch tabs themselves.

So far, the only method I can think of is adding the listener to the whole JTabbedPane. If the event isn't within the currently focused component, then it must be in one of the tabs, so I compare the tooltip for that point against the tooltip of the current tab, but this won't work properly if more than one tab has the same tooltip. Anyone have any better ideas?

[622 byte] By [AFlooda] at [2007-11-26 13:48:37]
# 1
Check out this posting: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=616577
camickra at 2007-7-8 1:24:44 > top of Java-index,Desktop,Core GUI APIs...
# 2

And you're well advised to use *only* methods on TabbedPaneUI without casting it to BasicTabbedPaneUI or any other specific UI delegate since that can throw a ClassCastException when run under different core or third-party look-and-feel. By the way, those are not real buttons (unfortunately), so you'll have to add the mouse listener to the entire tabbed pane (like in the linked example).

kirillga at 2007-7-8 1:24:44 > top of Java-index,Desktop,Core GUI APIs...