View TopComponents with icons on Netbeans RCP

This article explains an approach to enable tabs with icons to ‘view’ TopComponents.

This article appeared first on

The Problem

A typical Netbeans RCP application always displays TopComponents with ‘editor’ mode with their icon and their title, even if the tab runs out of space. Here is an example:


Tabs of editor TopComponents


TopComponents with other modes are displayed as ‘views’. Their tabs are extremely simplistic: they never show their icon and their title is shortened or even omitted in case of less space. Here is an example:


Tabs of view TopComponents (observe that the title of the focused tab is missing!)



Some thoughts about

Geertjan’s Blog explains in his blog how to completely hide tabs for ‘editor’ TopComponents, by setting the ‘EditorTabDisplayerUI’ UIManager property and overriding the inherited Look and Feel that renders the tab.

If there is an ‘editor’ tab displayer, wouldn’t there be a ‘view’ tab displayer? After some research, I found the analogous ‘ViewTabDisplayerUI’ UIManager property. But what would be the proper value? A self crafted class like Geertjan’s one? That would require too much work and it would not follow the current Look and Feel.

The Solution

As the editor tab displayer looks fine, I decided to reuse it as a view tab displayer provided by the current Look and Feel. That was quite simple, though audacious. To preserve the look and feel, copy the the EditorTabDisplayerUI property’s value to the ViewTabDisplayerUI UIManager property. This hack requires scheduling the code from an module installer to execute later in the UI thread, when the Look and Feel is already defined.

public class Installer extends ModuleInstall {
 public void restored() {
   SwingUtilities.invokeLater(new Runnable() {
     public void run() {
       final Object view = UIManager.get("ViewTabDisplayerUI");
       final Object editor = UIManager.get("EditorTabDisplayerUI");
       System.out.println("invokeLater: "+view);
       System.out.println("invokeLater: " +editor);
       UIManager.put("ViewTabDisplayerUI", editor);

I admit that it is a dirty hack, but it worked.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: