aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTabbedPane listener for: add, close and change selected tab Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTabbedPane listener for: add, close and change selected tab" Watch "JTabbedPane listener for: add, close and change selected tab" New topic
Author

JTabbedPane listener for: add, close and change selected tab

Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

What listener should I add to JTabbedPane, so I can "follow": opening new tab, closing tab, and changing selected tab?


The quieter you are, the more you are able to hear.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
If you add a ChangeListener to the JTabbedPane's SingleSelectionModel (obtained via getModel()), you can listen for selection changes. I think that to listen for addition and removal of tabs / components, you'll want to add a ComponentListener to the JTabbedPane, though I'm not 100% sure if this is the only or best way to do this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTabbedPane listener for: add, close and change selected tab
 
Similar Threads
JTabbedPan
JTabbedPane
change the focus to the new tab
show OptionDialog without JTabbedPane changing tab
How to load tab content upon clicking the tab in JTabbedPane?