Plug A Custom BasicTabbedPaneUI into the NetBeans Platform

Even better than the multi-row editor tabs in the upcoming NetBeans IDE 7.2 is how this new feature has been implemented. I guess Stan Aubrecht, the NetBeans window system engineer, must have thought: "If anyone ever wants a different tab layout ever again, they're just going to have to create it themselves!"

In a pluggable system, a thought like the above is supported very well indeed and so the NetBeans Platform now allows custom implementations of tab control. In a NetBeans module, I created the class below:

import org.netbeans.swing.tabcontrol.WinsysInfoForTabbedContainer;
import org.netbeans.swing.tabcontrol.customtabs.Tabbed;
import org.netbeans.swing.tabcontrol.customtabs.TabbedComponentFactory;
import org.netbeans.swing.tabcontrol.customtabs.TabbedType;
import org.openide.util.lookup.ServiceProvider;

@ServiceProvider(service = TabbedComponentFactory.class, position = 500)
public class CustomTabbedPaneFactory implements TabbedComponentFactory {

    public Tabbed createTabbedComponent(TabbedType type, WinsysInfoForTabbedContainer info) {
        JTabbedPaneAdapter tabPane = new JTabbedPaneAdapter(type, info);
        tabPane.setUI(new PlasticTabbedPaneUI());
        return tabPane.getTabbed();

And the result (because the 'position' attribute above is lower than the position of the NetBeans Platform's own BasicTabbedPaneUI):

The PlasticTabbedPaneUI is not my own—if you want to play with this and other tab displays, see this very useful blog entry which has several different examples, including a JAR that contains them all. (And here is a useful article.)


I am interested in trying to do customizing like this and am trying to get your example running. I am having trouble finding JTabbedPaneAdapter. Which jar is that in and more specifically, I am using maven so if you could provide the group and artifact ids, that would be incredibly helpful.



Posted by Bo Conroy on May 01, 2012 at 02:55 PM PDT #

Read the blog entry again. This is about NetBeans Platform 7.2. You'll need a development build if you want to use this today, since NetBeans Platform 7.2 does not exist yet.

Posted by Geertjan on May 02, 2012 at 03:42 AM PDT #

Right. I pointed to the maven repository for SNAPSHOT and was able to get a hold of the code for the TabbedComponentFactory, Tabbed and other new 7.2 classes.

I actually found the the JTabbedPaneAdapter in the artifact org-netbeans-core-windows. Unfortunately, when i try to compile a module that uses this, it tells me that I am not a friend of org-netbeans-core-windows and therefore cannot access code from that module.

I guess my fundamental question is (assuming I am pointing to the 7.2 code base), should I be able to compile and run the code you have above in a module of my own?



Posted by Bo Conroy on May 02, 2012 at 07:20 AM PDT #

Yes, you should be able to. But I'd wait for 7.2 to be released. Or use an Ant-based project with a 7.2 dev build since the Maven snapshot repo isn't kept up to date on a daily basis.

Posted by Geertjan on May 02, 2012 at 11:41 AM PDT #

Since Netbeans 7.2 was released a few days ago I decided try this solution to change the style of some TopComponents. I'm using maven on this project and was able to get the release-version of the Netbeans jars.

Sadly I'm still running into the same problem that Bo Conroy had. To use JTabbedPaneAdapter I had to include org-netbeans-core-windows in my dependencies. On compile I get an error telling me I'm not a friend of this module.

I found somewhere a solution to change the tabdesign. Though this solution involved implementing the abstract methods of Tabbed which include lots of behavior and are not well documented (no JavaDoc for single methods).

So my question is, is there an easy way (like your solution in this blog) to plug a custom UI that works with maven?


Posted by Adriana on July 26, 2012 at 12:57 AM PDT #

Hi Bo and Adriana,

Please read here:

Posted by Geertjan on July 26, 2012 at 03:59 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« July 2016