DevFaqDropdownMenuAddToolbarEnabled

Revision as of 02:59, 24 January 2010 by Tboudreau (Talk | contribs)

How do I add a dropdown menu to toolbar that is selectively enabled/disabled?

Create an Action - this can be a subclass of one of NetBeans Action subclasses, or simply a subclass of javax.swing.AbstractAction.

Have it implement Presenter.Toolbar. This interface indicates that your Action wants to provide its own component to show in the main window's toolbar. You can provide whatever Swing component you want.

Implement getToolbarPresenter() to create a JPopupMenu and pass it to DropDownButtonFactory.createDropDownButton and return that.

For a detailed example of manually creating a drop-down toolbar button (without DropDownButtonFactory, circa NetBeans 6.0), particularly a context-aware one, see see this post, posted in on the old dev@openide NetBeans mailing lists.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo