views:

667

answers:

2

This is similar to the question How to build a Google-chrome tabs and menubar interface in Java Swing? (I want to accomplish the same), but more to the point: How do I put components in front and behind the tabs in a JTabbedPane?

I've already come up with the buttons-idea myself, but I'd rather have a JTabbedPane, since that is really what it is, but decorated with a button or icons on the sides.

I've seen that the laf-widget project from Kirill does something like it (the magnifying-glass icon to the left of the tabs) for several LaFs. However, I must admit that I'm not yet well enough versed to understand how he does it - and also it seems like a somewhat complicated process, whereby one "physically" change the LaF in question (bytecode manipulates it), injecting the laf-widget stuff into the UI delegates - and I still don't know how the JTabbedPane or TabbedPaneUI is actually modulated to inject that icon/button.

A: 

I finally asked Kirill of Substance LaF/laf-widget of how he manages to put a button in front of the tabs in the laf-widget that decorates JTabbedPanes, and this is his reply:

It relies on the BasicTabbedPaneUI.tabAreaInsets field to make room for the button, and custom setBounds of the button component to position itself in that area.

For more code, see TabOverviewButton and TabOverviewDialogWidget classes in the laf-widget project.

In general, the tabbed pane UI delegate is one of the least attractive ones to enhance since it has a lot of private and package protected methods

Thanks, Kirill!

stolsvik
+1  A: 

JIDE have a tabbed pane as part of their component suite that exposes this functionality as simple setBeforeComponent() and setAfterComponent() methods.

There's a demo of it in here: http://www.jidesoft.com/products/1.4/jide_demo.jnlp

banjollity
It has?! Awesome - I just got pointed in the direction of Jide from another answer here on Stackoverflow, but hadn't gotten to check out the APIs yet - the screenshots doesn't hint towards such a feature at all. I guess one looses the LaF using Jide?
stolsvik
It depends what you're doing. The JIDE components are pretty good about honouring LaFs. We use it with synthetica and it's seamless.
banjollity
How does it depend? Do you have a pointer for where some documentation resides? I can't seem to find it. I try using it with Substance now, and it blatanly doesn't honor that. It seems to use some "vsnet" UI stuff of its own to paint.
stolsvik