Sollybird Sollybird - 15 days ago 9
Java Question

JTabbedPane click event

I need to be able to process a click on the tabs in a JTabbedPane. I'm not using this to change tabs, and this isn't going to trigger on tab change. What I'm attempting to do is close the tab when it is right clicked. However, I'm not sure how I can access the tab to add a click event on it. Most of the questions related to clicking on JTabbedPanes suggest using a ChangeListener, but that won't work, since the tabs aren't going to be changed on right click.

Is there any way for me to add a click event to a JTabbedPane's tab?

Answer

Is there any way for me to add a click event to a JTabbedPane's tab?

Read the section from the Swing tutorial on How to Use TabbedPanes for a working example on how to close a tab with a mouse click.

Keep a link to the tutorial handy for Swing basics.

Comments