Geertjan's Blog

  • December 10, 2015

Farewell to Space Consuming Weird Tabs (Part 2)

Geertjan Wielenga
Product Manager

Hermien Pellissier recently left a comment in a popular blog entry of mine from 2006 entitled "Farewell to Space Consuming Weird Tabs":

"I had trouble getting this to work with Java 8 too. So I decided to debug, and suddenly it just worked. This meant that it had to be a timing issue, quite possibly related to module load order. The solution that works for me as my code stands right now, is to add a Thread.sleep(500); before the UIManager.put() call."

I tried this today, since I've been having trouble as well since NetBeans IDE 8.1, which kind of makes sense since several internal changes have taken place within the NetBeans Platform for the NetBeans IDE 8.1 release (these changes have almost no impact, mainly focused on splitting up modules in new ways, rather than actual NetBeans API changes).

It didn't completely do the trick for me. Below is what's needed, as far as I can see. The @OnShowing is applicable for the first time the application starts up, i.e., with a fresh user directory. The @OnStart, together with the brief sleep, is what's needed for subsequent startups, i.e., at this point one or more TopComponents may already be open in the "editor" position and the @OnShowing will not be called anymore for those TopComponents, since they're already showing. Therefore, the @OnStart is needed, with the sleep (thanks Hermien), to ensure that the code is run again, thus hiding the tabs for those TopComponents that have already been opened.

import static java.lang.Thread.sleep;
import javax.swing.UIManager;
import org.openide.modules.OnStart;
import org.openide.windows.OnShowing;
public class ModuleInstall implements Runnable {
public void run() {
try {
} catch (InterruptedException ex) {
UIManager.put("EditorTabDisplayerUI", "org.aa.core.NoTabsTabDisplayerUI");

The complete sample is here:


How to use it: Git the sample, open into NetBeans IDE 8.1, run the application, go to Window | Web | Web Browser. The Web Browser should open, without showing a tab, since it opens in the "editor" position. Then leave the Web Browser open and close the application, don't clean it, i.e., don't remove the 'build' folder, which contains the user directory including the setting that the Web Browser should automatically be reopened by the NetBeans Platform because you didn't close it before closing the application; simply run it again and notice that the Web Browser is automatically opened, i.e., restored to how you had it when the application closed, while noticing especially that the Web Browser doesn't show a tab after the restart of the application. If you leave comments here saying "this doesn't work for me" and I find out you haven't got hold of the above app and actually tried it out, i.e., using my app, not yours, but mine first, I'll be very sad. Not angry, just really sad. Don't make me sad. Just actually git the sample, run it, confirm that it works there, and only then try to apply this solution to your own applications.

Join the discussion

Comments ( 1 )
  • Hermien Pellissier Thursday, December 10, 2015


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.