views:

379

answers:

1

Hi,

Is it possible to add a button to a tabbedpane like in firefox. Firefox The green plus-button is what I want.

Thanks

+2  A: 

I think you should be able to manage it by building your own JTabbedPaneUI and setting it on the JTabbedPane using setUI.

Your ComponentUI has methods to get a hold of the accessible children. If you specify a JButton and a JLabel then you may be in business.

I haven't attempted this myself though. This is "at your own risk" :)

Carl Smotricz
Using a custom UI is the way to go. I've done something similar before. For the "X" on the tab to close it, you can override the painting of the tab itself to include the X and install a mouse listener that checks if the user has selected that area with the X.
Jeff Storey
Sun's "Tabbed Panes" tutorial includes an example of just such a feature: http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html
trashgod