Search in sources :

Example 1 with SystemAction

use of org.openide.util.actions.SystemAction in project ACS by ACS-Community.

the class ActionUtils method createJButton.

/**
   * creates a JButton for the Action itself.
   * You should not need to use this method, rather use {@link #createJButton(Class)} 
   * If you find you need to use this action, please do not create actions yourself, 
   * use the {@link SystemAction#get(java.lang.Class) or {@link #actionForComp(TopComponent, Class)} instead.
   * 
   * @see #createJButton(Class) for more explanations
   * @return a JButton
   * @since 2.0.5
   */
public static JButton createJButton(Action act) {
    JButton but = new JButton();
    // [PENDING] there is a problem when getIcon returns null: by default the icon is replaced with a text.
    // [PENDING] this produces buttons with twice the label.
    // [PENDING] to change this, one would have to work on the Actions.ButtonBridge class and especially
    // [PENDING] on the useTextIcons() method in there.
    // [PENDING] we have tried changing the icon in this method, but it doesn't work. We believeit gets updated 
    // [PENDING] dynamically in the ButtonBridge class.
    Actions.connect(but, act);
    String label = "invalid";
    if (act instanceof SystemAction) {
        label = ((SystemAction) act).getName();
    } else {
        label = act.getValue(Action.NAME).toString();
    }
    Mnemonics.setLocalizedText(but, label);
    return but;
}
Also used : SystemAction(org.openide.util.actions.SystemAction) JButton(javax.swing.JButton)

Example 2 with SystemAction

use of org.openide.util.actions.SystemAction in project ACS by ACS-Community.

the class ActionUtils method createJButton.

/**
   * creates a JButton for the SystemAction itself.
   * You should not need to use this method, rather use {@link #createJButton(Class)} 
   * If you find you need to use this action, please do not create actions yourself, 
   * use the {@link SystemAction#get(java.lang.Class) or {@link #actionForComp(TopComponent, Class)} instead.
   * 
   * @see #createJButton(Class) for more explanations
   * @return a JButton
   * @deprecated -- use {@link #createJButton(Action)}
   */
public static JButton createJButton(SystemAction act) {
    JButton but = new JButton();
    // [PENDING] there is a problem when getIcon returns null: by default the icon is replaced with a text.
    // [PENDING] this produces buttons with twice the label.
    // [PENDING] to change this, one would have to work on the Actions.ButtonBridge class and especially
    // [PENDING] on the useTextIcons() method in there.
    // [PENDING] we have tried changing the icon in this method, but it doesn't work. We believeit gets updated 
    // [PENDING] dynamically in the ButtonBridge class.
    Action swingAction = act;
    Actions.connect(but, swingAction);
    Mnemonics.setLocalizedText(but, act.getName());
    return but;
}
Also used : SystemAction(org.openide.util.actions.SystemAction) ContextAwareAction(org.openide.util.ContextAwareAction) Action(javax.swing.Action) JButton(javax.swing.JButton)

Aggregations

JButton (javax.swing.JButton)2 SystemAction (org.openide.util.actions.SystemAction)2 Action (javax.swing.Action)1 ContextAwareAction (org.openide.util.ContextAwareAction)1