DevFaqDropdownMenuAddToolbarEnabled

(Difference between revisions)
(Updated for DropDownButtonFactory)
Line 1: Line 1:
__NOTOC__
__NOTOC__
-
[[CategoryNeedProofRead | CategoryNeedProofRead]] What was the question?
+
==How do I add a dropdown menu to toolbar that is selectively enabled/disabled?==
-
The basic idea is to combine a ContextAwareAction and a [[DevFaqDropdownMenuAddToolbar| Presenter.Toolbar]].
+
Create an Action - this can be a subclass of one of NetBeans Action subclasses, or simply a subclass of javax.swing.AbstractAction.
-
For details [http://article.gmane.org/gmane.comp.java.netbeans.modules.openide.devel/35436 see this post], posted in [http://thread.gmane.org/gmane.comp.java.netbeans.modules.openide.devel/35424 this thread of the NetBeans mailing lists].
+
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 [http://bits.netbeans.org/dev/javadoc/org-openide-awt/org/openide/awt/DropDownButtonFactory.html#createDropDownButton(javax.swing.Icon,%20javax.swing.JPopupMenu) 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 [http://article.gmane.org/gmane.comp.java.netbeans.modules.openide.devel/35436 see this post], posted in [http://thread.gmane.org/gmane.comp.java.netbeans.modules.openide.devel/35424 on the old dev@openide NetBeans mailing lists].

Revision as of 02:59, 24 January 2010

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