Oct 092012
 

Sometimes it is useful to be able to visually separate groups of buttons on the main application toolbar. However, the NetBeans Platform doesn’t add separators to the toolbar by default as it is able to for the menubar. When I recently saw the question being posed again, I decided that it is time to find a way to accomplish this. And the key was in fact the NetBeans IDE 7.2 Plugin Quick Start tutorial. That tutorial describes how you can add other components besides buttons to the toolbar.

I followed the tutorial, but I didn’t create a panel. Instead I implemented the getToolbarPresenter() as follows:

@Override
public Component getToolbarPresenter() {
    JSeparator separator = new JSeparator();
    separator.setOrientation(JSeparator.VERTICAL);
    return separator;
}

That is it. Now I have a separator between two of the buttons on the toolbar.

Separator on the toolbar

Separator on the toolbar

 Leave a Reply

(required)

(required)


− two = 1

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>