Geertjan's Blog

  • March 7, 2012

Plug A Custom BasicTabbedPaneUI into the NetBeans Platform

Geertjan Wielenga
Product Manager

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.core.windows.view.ui.tabcontrol.JTabbedPaneAdapter;
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.)

Join the discussion

Comments ( 6 )
  • Bo Conroy Tuesday, May 1, 2012

    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.



  • Geertjan Wednesday, May 2, 2012

    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.

  • Bo Conroy Wednesday, May 2, 2012

    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?



  • Geertjan Wednesday, May 2, 2012

    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.

  • Adriana Thursday, July 26, 2012

    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?



  • Geertjan Thursday, July 26, 2012
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.