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:org.kineticsystem.commons.data.view.actions.MoveForwardAction.java

/**
  * Constructor./*  ww  w .j  ava 2 s  .c  om*/
  * @param controller The navigator controller instance.
  */
public MoveForwardAction(Navigator navigator) {
    this.navigator = navigator;
    putValue(Action.SMALL_ICON, ResourceLoader.getIcon(NAVIGATOR_RESOURCE + "Next16.png"));
    putValue(Action.NAME, Localizer.localizeString(NAVIGATOR_BUNDLE, "MoveForwardAction"));
    putValue(Action.SHORT_DESCRIPTION,
            Localizer.localizeString(NAVIGATOR_BUNDLE, "MoveForwardAction_Description"));
    setEnabled(false);
}

From source file:org.kineticsystem.commons.data.view.actions.MoveForwardMouseAction.java

/**
 * Constructor.//from w w  w  .  j  a v a 2s .c  om
 * @param navigator The navigator instance.
 */
public MoveForwardMouseAction(Navigator navigator) {
    this.navigator = navigator;
    putValue(Action.SMALL_ICON, ResourceLoader.getIcon(NAVIGATOR_RESOURCE + "Next16.png"));
    putValue(Action.NAME, Localizer.localizeString(NAVIGATOR_BUNDLE, "MoveForwardAction"));
    putValue(Action.SHORT_DESCRIPTION,
            Localizer.localizeString(NAVIGATOR_BUNDLE, "MoveForwardAction_Description"));
    setEnabled(false);
}

From source file:org.languagetool.gui.Main.java

private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(getLabel("guiMenuFile"));
    fileMenu.setMnemonic(getMnemonic("guiMenuFile"));
    JMenu editMenu = new JMenu(getLabel("guiMenuEdit"));
    editMenu.setMnemonic(getMnemonic("guiMenuEdit"));
    JMenu grammarMenu = new JMenu(getLabel("guiMenuGrammar"));
    grammarMenu.setMnemonic(getMnemonic("guiMenuGrammar"));
    JMenu helpMenu = new JMenu(getLabel("guiMenuHelp"));
    helpMenu.setMnemonic(getMnemonic("guiMenuHelp"));

    fileMenu.add(openAction);//www. ja v  a  2  s. co m
    fileMenu.add(saveAction);
    fileMenu.add(saveAsAction);
    recentFilesMenu = new JMenu(getLabel("guiMenuRecentFiles"));
    recentFilesMenu.setMnemonic(getMnemonic("guiMenuRecentFiles"));
    fileMenu.add(recentFilesMenu);
    updateRecentFilesMenu();
    fileMenu.addSeparator();
    fileMenu.add(new HideAction());
    fileMenu.addSeparator();
    fileMenu.add(new QuitAction());

    grammarMenu.add(checkAction);
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(autoCheckAction);
    grammarMenu.add(item);
    JCheckBoxMenuItem showResult = new JCheckBoxMenuItem(showResultAction);
    grammarMenu.add(showResult);
    grammarMenu.add(new CheckClipboardAction());
    grammarMenu.add(new TagTextAction());
    grammarMenu.add(new AddRulesAction());
    grammarMenu.add(new OptionsAction());
    grammarMenu.add(new SelectFontAction());
    JMenu lafMenu = new JMenu(messages.getString("guiLookAndFeelMenu"));
    UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
    ButtonGroup buttonGroup = new ButtonGroup();
    for (UIManager.LookAndFeelInfo laf : lafInfo) {
        if (!"Nimbus".equals(laf.getName())) {
            continue;
        }
        addLookAndFeelMenuItem(lafMenu, laf, buttonGroup);
    }
    for (UIManager.LookAndFeelInfo laf : lafInfo) {
        if ("Nimbus".equals(laf.getName())) {
            continue;
        }
        addLookAndFeelMenuItem(lafMenu, laf, buttonGroup);
    }
    grammarMenu.add(lafMenu);

    helpMenu.add(new AboutAction());

    undoRedo.undoAction.putValue(Action.NAME, getLabel("guiMenuUndo"));
    undoRedo.undoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuUndo"));
    undoRedo.redoAction.putValue(Action.NAME, getLabel("guiMenuRedo"));
    undoRedo.redoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuRedo"));

    editMenu.add(undoRedo.undoAction);
    editMenu.add(undoRedo.redoAction);
    editMenu.addSeparator();

    Action cutAction = new DefaultEditorKit.CutAction();
    cutAction.putValue(Action.SMALL_ICON, getImageIcon("sc_cut.png"));
    cutAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_cut.png"));
    cutAction.putValue(Action.NAME, getLabel("guiMenuCut"));
    cutAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_T);
    editMenu.add(cutAction);

    Action copyAction = new DefaultEditorKit.CopyAction();
    copyAction.putValue(Action.SMALL_ICON, getImageIcon("sc_copy.png"));
    copyAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_copy.png"));
    copyAction.putValue(Action.NAME, getLabel("guiMenuCopy"));
    copyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
    editMenu.add(copyAction);

    Action pasteAction = new DefaultEditorKit.PasteAction();
    pasteAction.putValue(Action.SMALL_ICON, getImageIcon("sc_paste.png"));
    pasteAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_paste.png"));
    pasteAction.putValue(Action.NAME, getLabel("guiMenuPaste"));
    pasteAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_P);
    editMenu.add(pasteAction);

    editMenu.addSeparator();

    editMenu.add(new SelectAllAction());

    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(grammarMenu);
    menuBar.add(helpMenu);
    return menuBar;
}

From source file:org.nuclos.client.main.MainController.java

private Action createEntityAction(EntityMetaDataVO entitymetavo, String label, final boolean isNew,
        final Long processId, final String customUsage) {
    String entity = entitymetavo.getEntity();
    if (!getSecurityCache().isReadAllowedForEntity(entity)) {
        return null;
    }//ww  w . ja va 2 s  . c  om

    if (isNew && entitymetavo.isStateModel()
            && !getSecurityCache().isNewAllowedForModuleAndProcess(IdUtils.unsafeToId(entitymetavo.getId()),
                    IdUtils.unsafeToId(processId))) {
        return null;
    }

    Action action = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cmdCollectMasterData(evt, isNew, processId, customUsage);
        }
    };
    Pair<String, Character> nameAndMnemonic = MenuGenerator.getMnemonic(label);
    action.putValue(Action.NAME,
            customUsage == null ? nameAndMnemonic.x : String.format("%s (%s)", nameAndMnemonic.x, customUsage));
    if (nameAndMnemonic.y != null) {
        action.putValue(Action.MNEMONIC_KEY, (int) nameAndMnemonic.y.charValue());
    }
    action.setEnabled(true);
    action.putValue(Action.SMALL_ICON,
            MainFrame.resizeAndCacheTabIcon(Main.getInstance().getMainFrame().getEntityIcon(entity)));
    action.putValue(Action.ACTION_COMMAND_KEY, entity);
    if (!isNew && processId == null) {
        if (!StringUtils.isNullOrEmpty(entitymetavo.getAccelerator())
                && entitymetavo.getAcceleratorModifier() != null) {
            int keycode = entitymetavo.getAccelerator().charAt(0);
            if (keycode > 90)
                keycode -= 32;

            action.putValue(Action.ACCELERATOR_KEY,
                    KeyStroke.getKeyStroke(keycode, entitymetavo.getAcceleratorModifier().intValue()));
        } else if (!StringUtils.isNullOrEmpty(entitymetavo.getAccelerator())) {
            action.putValue(Action.ACCELERATOR_KEY,
                    KeyStroke.getKeyStroke(entitymetavo.getAccelerator().charAt(0)));
        }
    }

    return action;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.actions.DownloadAction.java

/**
 * Creates a new instance./* www. j  ava 2 s  .  com*/
 * 
 * @param model Reference to the Model. Mustn't be <code>null</code>.
 */
public DownloadAction(DataBrowser model) {
    super(model);
    putValue(Action.SHORT_DESCRIPTION, UIUtilities.formatToolTipText(DESCRIPTION));
    IconManager icons = IconManager.getInstance();
    putValue(Action.SMALL_ICON, icons.getIcon(IconManager.DOWNLOAD));
    putValue(Action.NAME, NAME);
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.DownloadAction.java

/**
 * Creates a new instance.//from w ww.ja v  a  2  s  .  c o m
 * 
 * @param model Reference to the Model. Mustn't be <code>null</code>.
 */
public DownloadAction(TreeViewer model) {
    super(model);
    name = NAME;
    putValue(Action.SHORT_DESCRIPTION, UIUtilities.formatToolTipText(DESCRIPTION));
    description = (String) getValue(Action.SHORT_DESCRIPTION);
    IconManager im = IconManager.getInstance();
    putValue(Action.SMALL_ICON, im.getIcon(IconManager.DOWNLOAD));
}

From source file:org.pdfsam.guiclient.commons.business.actions.SetOutputPathSelectionTableAction.java

/**
 * @param selectionPanel//  w  w w .j  a  v a2 s .c  o  m
 * @param destinationField
 *            the JTextField to update
 * @param defaultOutputFileName
 *            the output file name. If null it's ignored.
 */
public SetOutputPathSelectionTableAction(JPdfSelectionPanel selectionPanel, JTextField destinationField,
        String defaultOutputFileName) {
    super(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Set destination"));
    this.setEnabled(true);
    this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_DOWN_MASK));
    this.putValue(Action.SHORT_DESCRIPTION, GettextResource
            .gettext(Configuration.getInstance().getI18nResourceBundle(), "Set the destination path"));
    this.putValue(Action.SMALL_ICON, new ImageIcon(this.getClass().getResource("/images/set_outfile.png")));
    this.selectionPanel = selectionPanel;
    this.destinationField = destinationField;
    this.defaultOutputFileName = defaultOutputFileName;
}

From source file:org.pdfsam.plugin.merge.actions.SaveListAsXmlAction.java

/**
 * @param selectionPanel/*from  ww  w . j a  v  a2s.  c  o  m*/
 */
public SaveListAsXmlAction(JPdfSelectionPanel selectionPanel) {
    super(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Export as xml"));
    this.setEnabled(true);
    this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_DOWN_MASK));
    this.putValue(Action.SHORT_DESCRIPTION, GettextResource.gettext(
            Configuration.getInstance().getI18nResourceBundle(), "Export the selection list in xml format"));
    this.putValue(Action.SMALL_ICON, new ImageIcon(this.getClass().getResource("/images/saveXml.png")));
    this.selectionPanel = selectionPanel;
}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingButton.java

protected void installAction(final Action newAction) {
    if (newAction != null) {
        setTooltiptext((String) action.getValue(Action.SHORT_DESCRIPTION));
        setLabel((String) action.getValue(Action.NAME));
        setDisabled(action.isEnabled() == false);
        setIcon((Icon) action.getValue(Action.SMALL_ICON));

        getButton().setAction(newAction);
        newAction.addPropertyChangeListener(actionChangeHandler);

        final Object o = newAction.getValue(Action.ACCELERATOR_KEY);
        if (o instanceof KeyStroke) {
            final KeyStroke k = (KeyStroke) o;
            getButton().registerKeyboardAction(newAction, k, JComponent.WHEN_IN_FOCUSED_WINDOW);
        }//from   ww  w.  jav  a  2 s . co m

        if (newAction instanceof ToggleStateAction) {
            final ToggleStateAction tsa = (ToggleStateAction) action;
            setSelected(tsa.isSelected());
        }
    }

}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.actions.ExportAction.java

/**
 * Defines an <code>Action</code> object with a default description string and default icon.
 *//*from   w  w w .j av a 2  s  .com*/
public ExportAction(final ExportActionPlugin actionPlugin, final PreviewPane previewPane) {
    if (actionPlugin == null) {
        throw new NullPointerException();
    }
    if (previewPane == null) {
        throw new NullPointerException();
    }

    this.actionPlugin = actionPlugin;
    this.previewPane = previewPane;
    putValue(Action.NAME, actionPlugin.getDisplayName());
    putValue(Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription());
    putValue(Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey());
    putValue(Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey());
    putValue(Action.SMALL_ICON, actionPlugin.getSmallIcon());
    putValue(SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon());
    this.actionPlugin.addPropertyChangeListener("enabled", new EnableChangeListener()); //$NON-NLS-1$

    setEnabled(actionPlugin.isEnabled());
}