Example usage for javax.swing Action SMALL_ICON

List of usage examples for javax.swing Action SMALL_ICON

Introduction

In this page you can find the example usage for javax.swing Action SMALL_ICON.

Prototype

String SMALL_ICON

To view the source code for javax.swing Action SMALL_ICON.

Click Source Link

Document

The key used for storing a small Icon, such as ImageIcon.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final Action action = new AbstractAction("Action Name") {
        {/*w w  w . ja v  a 2  s  .c om*/
            putValue(Action.SHORT_DESCRIPTION, "Tool Tip Text");

            putValue(Action.LONG_DESCRIPTION, "Help Text");

            Icon icon = new ImageIcon("icon.gif");
            putValue(Action.SMALL_ICON, icon);

            putValue(Action.MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_A));
            putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control F2"));
        }

        public void actionPerformed(ActionEvent evt) {
            System.out.println("action");
        }
    };

    JButton button = new JButton(action);
}

From source file:ColorAction.java

public ColorAction(String name, Icon icon, Color c, Component comp) {
    putValue(Action.NAME, name);//from w w w . j a  v  a  2s.c om
    putValue(Action.SMALL_ICON, icon);
    putValue("Color", c);
    target = comp;
}

From source file:Main.java

public ShowAction() {
    super("About");
    putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A));
    putValue(Action.SMALL_ICON, MetalIconFactory.getFileChooserHomeFolderIcon());
}

From source file:ActionChangedListener.java

public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    System.out.println(propertyName);
    if (e.getPropertyName().equals(Action.NAME)) {
        String text = (String) e.getNewValue();
        button.setText(text);//from   w ww .  ja v  a2  s  . c  om
        button.repaint();
    } else if (propertyName.equals("enabled")) {
        Boolean enabledState = (Boolean) e.getNewValue();
        button.setEnabled(enabledState.booleanValue());
        button.repaint();
    } else if (e.getPropertyName().equals(Action.SMALL_ICON)) {
        Icon icon = (Icon) e.getNewValue();
        button.setIcon(icon);
        button.invalidate();
        button.repaint();
    }
}

From source file:org.jdal.swing.IconAction.java

public Icon getIcon() {
    return (Icon) getValue(Action.SMALL_ICON);
}

From source file:org.jdal.swing.IconAction.java

public void setIcon(Icon icon) {
    putValue(Action.SMALL_ICON, icon);
}

From source file:net.sf.jabref.gui.menus.help.DonateAction.java

public DonateAction() {
    super(Localization.menuTitle("Donate to JabRef"));
    putValue(Action.SHORT_DESCRIPTION, Localization.lang("Donate to JabRef"));
    putValue(Action.SMALL_ICON, IconTheme.JabRefIcon.DONATE.getSmallIcon());
    putValue(Action.LARGE_ICON_KEY, IconTheme.JabRefIcon.DONATE.getIcon());
}

From source file:com.sshtools.common.ui.NewWindowAction.java

/**
 * Creates a new NewWindowAction object.
 *
 * @param application//from  w ww. ja v a2  s . c om
 */
public NewWindowAction(SshToolsApplication application) {
    this.application = application;

    putValue(Action.NAME, "New Window");
    putValue(Action.SMALL_ICON, getIcon("/com/sshtools/common/ui/newwindow.png"));
    putValue(LARGE_ICON, getIcon("/com/sshtools/common/ui/largenewwindow.png"));
    putValue(Action.SHORT_DESCRIPTION, "Create new window");
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.ALT_MASK));
    putValue(Action.LONG_DESCRIPTION, "Create a new SSHTerm window");
    putValue(Action.MNEMONIC_KEY, new Integer('w'));
    putValue(Action.ACTION_COMMAND_KEY, "new-window");
    putValue(StandardAction.ON_MENUBAR, new Boolean(true));
    putValue(StandardAction.MENU_NAME, "File");
    putValue(StandardAction.MENU_ITEM_GROUP, new Integer(0));
    putValue(StandardAction.MENU_ITEM_WEIGHT, new Integer(90));
    putValue(StandardAction.ON_TOOLBAR, new Boolean(true));
    putValue(StandardAction.TOOLBAR_GROUP, new Integer(0));
    putValue(StandardAction.TOOLBAR_WEIGHT, new Integer(90));
}

From source file:ca.sfu.federation.action.CreateScenarioAction.java

public CreateScenarioAction() {
    super("Create Scenario", null);
    Icon icon = ImageIconUtils.loadIconById("model-create-scenario");
    this.putValue(Action.LONG_DESCRIPTION, "Create Scenario");
    this.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
    this.putValue(Action.SHORT_DESCRIPTION, "Create Scenario");
    this.putValue(Action.SMALL_ICON, icon);
}

From source file:ca.sfu.federation.action.CreateAssemblyAction.java

public CreateAssemblyAction() {
    super("Create Assembly", null);
    Icon icon = ImageIconUtils.loadIconById("model-create-assembly");
    this.putValue(Action.LONG_DESCRIPTION, "Create Assembly");
    this.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A);
    this.putValue(Action.SHORT_DESCRIPTION, "Create Assembly");
    this.putValue(Action.SMALL_ICON, icon);
}