Example usage for javax.swing Action LARGE_ICON_KEY

List of usage examples for javax.swing Action LARGE_ICON_KEY

Introduction

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

Prototype

String LARGE_ICON_KEY

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

Click Source Link

Document

The key used for storing an Icon.

Usage

From source file:Main.java

public ShowAction() {
    super("About");

    putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A));
    putValue(Action.NAME, "Go to number ");
    putValue(Action.LARGE_ICON_KEY, MetalIconFactory.getFileChooserHomeFolderIcon());

}

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

public ForkMeOnGitHubAction() {
    super(Localization.menuTitle("Fork me on GitHub"), IconTheme.JabRefIcon.GITHUB.getSmallIcon());
    putValue(Action.SHORT_DESCRIPTION, Localization.lang("Opens JabRef's GitHub page"));
    putValue(Action.LARGE_ICON_KEY, IconTheme.JabRefIcon.GITHUB.getIcon());
}

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:Main.java

/**
 * //from  ww w  .j a v a 2 s .  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.opendoorlogistics.studio.appframe.AppFrame.java

private void initToolbar(ActionFactory actionBuilder, List<? extends Action> fileActions,
        List<? extends Action> editActions) {
    getContentPane().add(mainToolbar, BorderLayout.WEST);

    mainToolbar.setFloatable(false);/* w w  w . j a  va 2s.  c  o  m*/

    mainToolbar.removeAll();
    for (Action action : fileActions) {
        if (action != null && action.getValue(Action.LARGE_ICON_KEY) != null) {
            mainToolbar.add(action);
        }
    }
    for (Action action : editActions) {
        if (action != null && action.getValue(Action.LARGE_ICON_KEY) != null) {
            mainToolbar.add(action);
        }
    }

    Action helpsite = actionBuilder.createGotoWebsiteAction(this);
    if (helpsite != null) {
        mainToolbar.add(helpsite);
    }

    mainToolbar.revalidate();
    mainToolbar.repaint();
}

From source file:ca.phon.app.project.ProjectWindow.java

private MultiActionButton createNewCorpusButton() {
    MultiActionButton retVal = new MultiActionButton();

    ImageIcon folderNewIcn = IconManager.getInstance().getIcon("places/folder", IconSize.SMALL);
    ImageIcon newIcnL = IconManager.getInstance().getIcon("actions/list-add", IconSize.MEDIUM);
    ImageIcon removeIcnL = IconManager.getInstance().getIcon("actions/list-remove", IconSize.MEDIUM);
    ImageIcon renameIcnL = IconManager.getInstance().getIcon("actions/edit-rename", IconSize.MEDIUM);

    String s1 = "Corpus";

    retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1));
    retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    retVal.getTopLabel().setFont(FontPreferences.getTitleFont());
    retVal.getTopLabel().setIcon(folderNewIcn);
    retVal.setOpaque(false);//w  ww  .j  av a2  s.  c om

    PhonUIAction newAct = new PhonUIAction(this, "onSwapNewAndCreateCorpus", retVal);
    newAct.putValue(Action.LARGE_ICON_KEY, newIcnL);
    newAct.putValue(Action.SMALL_ICON, folderNewIcn);
    newAct.putValue(Action.NAME, "New corpus");
    newAct.putValue(Action.SHORT_DESCRIPTION, "Create a new corpus folder");

    DeleteCorpusAction deleteCurrentAct = new DeleteCorpusAction(this);
    deleteCurrentAct.putValue(Action.LARGE_ICON_KEY, removeIcnL);

    PhonUIAction renameCurrentAct = new PhonUIAction(this, "onRenameCorpus");
    renameCurrentAct.putValue(Action.LARGE_ICON_KEY, renameIcnL);
    renameCurrentAct.putValue(Action.NAME, "Rename corpus");
    renameCurrentAct.putValue(Action.SHORT_DESCRIPTION, "Rename selected corpus");

    retVal.setDisplayDefaultAction(true);
    retVal.addAction(deleteCurrentAct);
    retVal.addAction(renameCurrentAct);

    retVal.setDefaultAction(newAct);

    retVal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return retVal;
}

From source file:ca.phon.app.project.ProjectWindow.java

private MultiActionButton createCorpusButton() {
    MultiActionButton retVal = new MultiActionButton();

    ImageIcon newIcn = IconManager.getInstance().getIcon("places/folder", IconSize.SMALL);

    String s1 = "Corpus";
    String s2 = "Enter corpus name and press enter.  Press escape to cancel.";

    retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1));
    retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    retVal.getTopLabel().setFont(FontPreferences.getTitleFont());
    retVal.getTopLabel().setIcon(newIcn);
    retVal.setAlwaysDisplayActions(true);

    retVal.setOpaque(false);//  ww w  .  j  a  v  a 2 s. co  m

    ImageIcon cancelIcn = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL);
    ImageIcon cancelIcnL = cancelIcn;

    PhonUIAction btnSwapAct = new PhonUIAction(this, "onSwapNewAndCreateCorpus", retVal);
    btnSwapAct.putValue(Action.ACTION_COMMAND_KEY, "CANCEL_CREATE_ITEM");
    btnSwapAct.putValue(Action.NAME, "Cancel create");
    btnSwapAct.putValue(Action.SHORT_DESCRIPTION, "Cancel create");
    btnSwapAct.putValue(Action.SMALL_ICON, cancelIcn);
    btnSwapAct.putValue(Action.LARGE_ICON_KEY, cancelIcnL);
    retVal.addAction(btnSwapAct);

    JPanel corpusNamePanel = new JPanel(new BorderLayout());
    corpusNamePanel.setOpaque(false);

    final JTextField corpusNameField = new JTextField();
    corpusNameField.setDocument(new NameDocument());
    corpusNameField.setText("Corpus Name");
    corpusNamePanel.add(corpusNameField, BorderLayout.CENTER);

    ActionMap actionMap = retVal.getActionMap();
    actionMap.put(btnSwapAct.getValue(Action.ACTION_COMMAND_KEY), btnSwapAct);
    InputMap inputMap = retVal.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);

    inputMap.put(ks, btnSwapAct.getValue(Action.ACTION_COMMAND_KEY));

    retVal.setActionMap(actionMap);
    retVal.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);

    PhonUIAction createNewCorpusAct = new PhonUIAction(this, "onCreateCorpus", corpusNameField);
    createNewCorpusAct.putValue(Action.SHORT_DESCRIPTION, "Create new corpus folder");
    createNewCorpusAct.putValue(Action.SMALL_ICON,
            IconManager.getInstance().getIcon("actions/list-add", IconSize.SMALL));

    JButton createBtn = new JButton(createNewCorpusAct);
    corpusNamePanel.add(createBtn, BorderLayout.EAST);

    corpusNameField.setAction(createNewCorpusAct);

    // swap bottom component in new project button
    retVal.setBottomLabelText(WorkspaceTextStyler.toDescText(s2));
    retVal.add(corpusNamePanel, BorderLayout.CENTER);

    retVal.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
        }

        @Override
        public void focusGained(FocusEvent e) {
            corpusNameField.requestFocus();
        }
    });

    return retVal;
}

From source file:ca.phon.app.project.ProjectWindow.java

private MultiActionButton createNewSessionButton() {
    MultiActionButton retVal = new MultiActionButton();

    ImageIcon newIcn = IconManager.getInstance().getIcon("mimetypes/text-xml", IconSize.SMALL);
    ImageIcon newIcnL = IconManager.getInstance().getIcon("actions/list-add", IconSize.MEDIUM);
    ImageIcon removeIcnL = IconManager.getInstance().getIcon("actions/list-remove", IconSize.MEDIUM);
    ImageIcon renameIcnL = IconManager.getInstance().getIcon("actions/edit-rename", IconSize.MEDIUM);
    ImageIcon openIcnL = IconManager.getInstance().getIcon("actions/view", IconSize.MEDIUM);

    String s1 = "Session";

    retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1));
    retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    retVal.getTopLabel().setFont(FontPreferences.getTitleFont());
    retVal.getTopLabel().setIcon(newIcn);
    retVal.setOpaque(false);//from  w  ww . j  av  a2 s.c  o  m

    PhonUIAction newAct = new PhonUIAction(this, "onSwapNewAndCreateSession", retVal);
    newAct.putValue(Action.LARGE_ICON_KEY, newIcnL);
    newAct.putValue(Action.SMALL_ICON, newIcn);
    newAct.putValue(Action.NAME, "New session");
    newAct.putValue(Action.SHORT_DESCRIPTION, "Create a new session in selected corpus");
    retVal.setDefaultAction(newAct);

    DeleteSessionAction deleteCurrentAct = new DeleteSessionAction(this);
    deleteCurrentAct.putValue(Action.LARGE_ICON_KEY, removeIcnL);

    PhonUIAction renameCurrentAct = new PhonUIAction(this, "onRenameSession");
    renameCurrentAct.putValue(Action.LARGE_ICON_KEY, renameIcnL);
    renameCurrentAct.putValue(Action.NAME, "Rename session");
    renameCurrentAct.putValue(Action.SHORT_DESCRIPTION, "Rename selected session");

    PhonUIAction openCurrentAct = new PhonUIAction(this, "onOpenSession");
    openCurrentAct.putValue(Action.LARGE_ICON_KEY, openIcnL);
    openCurrentAct.putValue(Action.NAME, "Open session");
    openCurrentAct.putValue(Action.SHORT_DESCRIPTION, "Open selected session");

    retVal.setDisplayDefaultAction(true);
    retVal.addAction(deleteCurrentAct);
    retVal.addAction(renameCurrentAct);
    retVal.addAction(openCurrentAct);

    retVal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return retVal;
}

From source file:ca.phon.app.project.ProjectWindow.java

private MultiActionButton createSessionButton() {
    MultiActionButton retVal = new MultiActionButton();

    ImageIcon newIcn = IconManager.getInstance().getIcon("mimetypes/text-xml", IconSize.SMALL);

    String s1 = "Session";
    String s2 = "Enter session name and press enter.  Press escape to cancel.";

    retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1));
    retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    retVal.getTopLabel().setFont(FontPreferences.getTitleFont());
    retVal.getTopLabel().setIcon(newIcn);
    retVal.setAlwaysDisplayActions(true);

    retVal.setOpaque(false);/*w  w w. j  a  v  a 2  s .co  m*/

    ImageIcon cancelIcn = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL);
    ImageIcon cancelIcnL = cancelIcn;

    PhonUIAction btnSwapAct = new PhonUIAction(this, "onSwapNewAndCreateSession", retVal);
    btnSwapAct.putValue(Action.ACTION_COMMAND_KEY, "CANCEL_CREATE_ITEM");
    btnSwapAct.putValue(Action.NAME, "Cancel create");
    btnSwapAct.putValue(Action.SHORT_DESCRIPTION, "Cancel create");
    btnSwapAct.putValue(Action.SMALL_ICON, cancelIcn);
    btnSwapAct.putValue(Action.LARGE_ICON_KEY, cancelIcnL);
    retVal.addAction(btnSwapAct);

    JPanel sessionNamePanel = new JPanel(new BorderLayout());
    sessionNamePanel.setOpaque(false);

    final JTextField sessionNameField = new JTextField();
    sessionNameField.setDocument(new NameDocument());
    sessionNameField.setText("Session Name");
    sessionNamePanel.add(sessionNameField, BorderLayout.CENTER);

    ActionMap actionMap = retVal.getActionMap();
    actionMap.put(btnSwapAct.getValue(Action.ACTION_COMMAND_KEY), btnSwapAct);
    InputMap inputMap = retVal.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);

    inputMap.put(ks, btnSwapAct.getValue(Action.ACTION_COMMAND_KEY));

    retVal.setActionMap(actionMap);
    retVal.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);

    PhonUIAction createNewSessionAct = new PhonUIAction(this, "onCreateSession", sessionNameField);
    createNewSessionAct.putValue(Action.SHORT_DESCRIPTION, "Create new session in selected corpus");
    createNewSessionAct.putValue(Action.SMALL_ICON,
            IconManager.getInstance().getIcon("actions/list-add", IconSize.SMALL));

    JButton createBtn = new JButton(createNewSessionAct);
    sessionNamePanel.add(createBtn, BorderLayout.EAST);

    sessionNameField.setAction(createNewSessionAct);

    // swap bottom component in new project button
    retVal.setBottomLabelText(WorkspaceTextStyler.toDescText(s2));
    retVal.add(sessionNamePanel, BorderLayout.CENTER);

    retVal.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {

        }

        @Override
        public void focusGained(FocusEvent e) {
            sessionNameField.requestFocus();
        }
    });

    return retVal;
}

From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java

private void updatePlotSpecimenIcon() {
    ImageIcon icon = null;// ww w  .jav a  2s.c  o m
    switch (onlyPlotOrSpecimen) {
    case ALL:
        icon = inactivePlotOrSpecimenFilterIcon;
        break;
    case ONLY_PLOTS:
        icon = activePlotFilterIcon;
        break;
    case ONLY_SPECIMENS:
        icon = activeSpecimenFilterIcon;
        break;
    default:
        break;
    }
    if (icon != null) {
        plotOrSpecimenFilterAction.putValue(Action.LARGE_ICON_KEY, icon);
    }
}