Geertjan's Blog

  • June 23, 2014

Floatable Toolbars on the NetBeans Platform

Geertjan Wielenga
Product Manager

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.

Join the discussion

Comments ( 2 )
  • guest Thursday, July 3, 2014

    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

  • Kevin Moore Thursday, July 3, 2014

    Found them, they are in the Datasystems API

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