Example usage for javax.swing AbstractButton setHideActionText

List of usage examples for javax.swing AbstractButton setHideActionText

Introduction

In this page you can find the example usage for javax.swing AbstractButton setHideActionText.

Prototype

@BeanProperty(expert = true, description = "Whether the text of the button should come from the <code>Action</code>.")
public void setHideActionText(boolean hideActionText) 

Source Link

Document

Sets the hideActionText property, which determines whether the button displays text from the Action.

Usage

From source file:Main.java

/**
 * /*from  w  w  w  .j  a v a 2s. co m*/
 * TODO
 * @param action
 * @return
 */
public static AbstractButton createToolbarItem(Action action) {
    final AbstractButton button;
    if (action == null) {
        throw new NullPointerException("Action cannot be null!");
    } else if (action.getValue(Action.SELECTED_KEY) != null) {
        button = new JToggleButton(action);
    } else {
        button = new JButton(action);
    }

    button.setOpaque(false);
    // hide text if icon is available
    if (action != null
            && (action.getValue(Action.SMALL_ICON) != null || action.getValue(Action.LARGE_ICON_KEY) != null)) {
        button.setHideActionText(true);
    }
    button.setHorizontalTextPosition(JButton.CENTER);
    button.setVerticalTextPosition(JButton.BOTTOM);
    return button;
}

From source file:com.mightypocket.ashot.Mediator.java

private JToolBar createToolBar() {
    ApplicationActionMap actionMap = getActionMap();
    JToolBar bar = new JToolBar();
    bar.setRollover(true);/* ww w .ja v a 2 s.c  o  m*/
    toolBarMap.clear();
    final boolean hideText = !p.getBoolean(PREF_GUI_SHOW_TEXT_IN_TOOLBAR, true);
    for (String actionName : TOOLBAR) {
        if (TOOLBAR_SEPARATOR.equals(actionName)) {
            bar.addSeparator();
        } else {
            AbstractButton bt;
            if (actionName.startsWith(TOOLBAR_TOGGLE_BUTTON)) {
                actionName = StringUtils.substring(actionName, TOOLBAR_TOGGLE_BUTTON.length());
                bt = new JToggleButton(actionMap.get(actionName));
            } else {
                bt = new JButton(actionMap.get(actionName));
            }
            bt.setFocusable(false);
            bt.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
            bt.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
            bt.setHideActionText(hideText);
            bar.add(bt);
            toolBarMap.put(actionName, bt);
        }
    }

    return bar;
}