Floatable Toolbars on the NetBeans Platform

So you're creating your awesome application on the NetBeans Platform...

But... you want the toolbars to be floatable. 

Notice that above there are now suddenly new 'floatable' markers to the left of each toolbar, indicating that you can drag the toolbar out of the toolbar container, as has been done for two toolbars here:

Here's how:

import org.openide.awt.Toolbar;
import org.openide.awt.ToolbarPool;
import org.openide.windows.OnShowing;

public class Startable implements Runnable {
    public void run() {
        ToolbarPool tb = ToolbarPool.getDefault();
        Toolbar[] toolbars = tb.getToolbars();
        for (Toolbar toolbar : toolbars) {

Note that this only works, to my knowledge anyway, with Nimbus. At least, I tried with Metal and I didn't see the handles for dragging and hence probably the same is true for other look and feels. To return a toolbar to the toolbar container, click the "x", i.e., the close button top left in the dialog that contains it. Also, there's a "Reset Toolbars" menu item in the toolbar which you probably want to remove/hide if you're using the solution above because it causes strange behavior in the above scenario.


Where are these imports? I do not find org.openide.awt.Toolbar or org.openide.awt.ToolbarPool in UI Utilities API in Netbeans 8.0

Posted by guest on July 03, 2014 at 10:21 AM PDT #

Found them, they are in the Datasystems API

Posted by Kevin Moore on July 03, 2014 at 10:26 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.


« August 2015