JTabbedPane: components before and after the tabs themselves

This seems like a question. How do I create Google Chrome tabs and an interface in Java Swing? (I want to do the same), but more to the point: how to put components in front and behind tabs in JTabbedPane?

I myself came up with the idea of ​​buttons, but I would prefer to use JTabbedPane, as this is really what it is, but is decorated with a button or icons on the sides.

I saw that the laf-widget project from Cyril does something like this (magnifying glass icon to the left of the tab) for several LaFs. Nevertheless, I must admit that I still do not understand how he does it - and it also seems to be a rather complicated process in which one “physically” changes the LaF in question (the byte code manipulates it), introducing laf-widget in the UI delegates - and I still don't know how the JTabbedPane or TabbedPaneUI is actually modulated to introduce this icon / button.

0
source share
2 answers

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

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

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

In general, the delegated tabbed user interface is one of the least attractive for promotion, as it has many private and batch protected methods.

Thank you, Cyril!

+1
source

JIDE have a tabbed panel as part of their component set, which provides this functionality as the simple setBeforeComponent () and setAfterComponent () methods.

There is a demo here: http://www.jidesoft.com/products/1.4/jide_demo.jnlp

+1
source

All Articles