Example usage for javax.swing Action NAME

List of usage examples for javax.swing Action NAME

Introduction

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

Prototype

String NAME

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

Click Source Link

Document

The key used for storing the String name for the action, used for a menu or button.

Usage

From source file:net.sf.jabref.importer.OpenDatabaseAction.java

public OpenDatabaseAction(JabRefFrame frame, boolean showDialog) {
    super(IconTheme.JabRefIcon.OPEN.getIcon());
    this.frame = frame;
    this.showDialog = showDialog;
    putValue(Action.NAME, Localization.menuTitle("Open database"));
    putValue(Action.ACCELERATOR_KEY, Globals.getKeyPrefs().getKey(KeyBinding.OPEN_DATABASE));
    putValue(Action.SHORT_DESCRIPTION, Localization.lang("Open BibTeX database"));
}

From source file:org.kepler.gui.kar.OpenArchiveAction.java

/**
 * Constructor//w w w.  j a v  a 2s  .c o m
 *
 * @param parent the "frame" (derived from ptolemy.gui.Top) where the menu is
 *               being added.
 */
public OpenArchiveAction(TableauFrame parent) {
    super("Open...");

    if (parent == null) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "OpenArchiveAction constructor received NULL argument for TableauFrame");
        iae.fillInStackTrace();
        throw iae;
    }
    this.parent = parent;

    this.putValue(Action.NAME, DISPLAY_NAME);
    this.putValue(GUIUtilities.LARGE_ICON, LARGE_ICON);
    this.putValue("tooltip", TOOLTIP);
    this.putValue(GUIUtilities.ACCELERATOR_KEY, ACCELERATOR_KEYSTROKE);
}

From source file:org.apache.jmeter.gui.action.SearchTreeDialog.java

@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    // Hide Window on ESC
    Action escapeAction = new AbstractAction("ESCAPE") {

        private static final long serialVersionUID = -6543764044868772971L;

        @Override//  w w  w.j  av a  2  s .  c o m
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    // Do search on Enter
    Action enterAction = new AbstractAction("ENTER") {

        private static final long serialVersionUID = -3661361497864527363L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            doSearch(actionEvent);
        }
    };
    ActionMap actionMap = rootPane.getActionMap();
    actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
    actionMap.put(enterAction.getValue(Action.NAME), enterAction);
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));

    return rootPane;
}

From source file:org.kepler.gui.AuthenticateAction.java

/**
 * Constructor/*from   ww  w.  j a va  2 s  .  c om*/
 * 
 * @param parent
 *            the "frame" (derived from ptolemy.gui.Top) where the menu is
 *            being added.
 */
public AuthenticateAction(TableauFrame parent) {
    super("");
    if (parent == null) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "AuthenticateAction constructor received NULL argument for TableauFrame");
        iae.fillInStackTrace();
        throw iae;
    }
    this.parent = parent;

    this.putValue(Action.NAME, DISPLAY_NAME);
    this.putValue(GUIUtilities.LARGE_ICON, LARGE_ICON);
    this.putValue("tooltip", TOOLTIP);
    this.putValue(GUIUtilities.ACCELERATOR_KEY, ACCELERATOR_KEY);
}

From source file:org.kepler.gui.RunWithFeedbackChkBoxAction.java

/**
 * Constructor//from w  w w. j a  v  a 2  s  .co m
 * 
 * @param parent
 *            the "frame" (derived from ptolemy.gui.Top) where the menu is
 *            being added.
 */
public RunWithFeedbackChkBoxAction(TableauFrame parent) {
    super("");
    if (parent == null) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "RunWithFeedbackChkBoxAction constructor received NULL argument for TableauFrame");
        iae.fillInStackTrace();
        throw iae;
    }
    this.putValue(Action.NAME, DISPLAY_NAME);
    this.putValue(GUIUtilities.LARGE_ICON, LARGE_ICON);
    this.putValue(GUIUtilities.MNEMONIC_KEY, MNEMONIC_KEY);
    this.putValue("tooltip", TOOLTIP);
    this.putValue(GUIUtilities.ACCELERATOR_KEY, ACCELERATOR_KEY);
}

From source file:UndoExample5.java

public void createMenuBar() {
    // Remove the existing menu items
    int count = menuBar.getMenuCount();
    for (int i = 0; i < count; i++) {
        menuBar.remove(menuBar.getMenu(0));
    }//from w  ww . ja v  a  2  s .  c  o  m

    // Build the new menu.
    Action[] actions = pane.getActions();
    Hashtable actionHash = new Hashtable();
    count = actions.length;
    for (int i = 0; i < count; i++) {
        actionHash.put(actions[i].getValue(Action.NAME), actions[i]);
    }

    // Add the font menu
    JMenu menu = MenuBuilder.buildMenu("Font", fontSpec, actionHash);
    if (menu != null) {
        menuBar.add(menu);
    }

    // Add the alignment menu
    menu = MenuBuilder.buildMenu("Align", alignSpec, actionHash);
    if (menu != null) {
        menuBar.add(menu);
    }
}

From source file:org.kepler.gui.component.OpenCompositeAction.java

/**
 * Constructor/*from   w  ww  . ja  va 2s. co  m*/
 * 
 *@param parent
 *            the "frame" (derived from ptolemy.gui.Top) where the menu is
 *            being added.
 */
public OpenCompositeAction(TableauFrame parent) {
    super("Open Archive (KAR)");
    if (parent == null) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "OpenCompositeAction constructor received NULL argument for TableauFrame");
        iae.fillInStackTrace();
        throw iae;
    }
    this.parent = parent;

    this.putValue(Action.NAME, DISPLAY_NAME);
    this.putValue(GUIUtilities.LARGE_ICON, LARGE_ICON);
    this.putValue("tooltip", TOOLTIP);
    this.putValue(GUIUtilities.ACCELERATOR_KEY, ACCELERATOR_KEY);
}

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

/**
 * Returns the name of the action.//  w w w  .  j a v  a 2s. c om
 * 
 * @return See above.
 */
public String getActionName() {
    if (StringUtils.isEmpty(name))
        return (String) getValue(Action.NAME);
    return name;
}

From source file:com.generalbioinformatics.rdf.gui.ProjectManager.java

private void refreshRecentFilesMenu() {
    for (int i = 0; i < MarrsPreference.RECENT_FILE_NUM; ++i) {
        AbstractAction act = recentActions[i];
        RecentItem item = (i >= recentItems.size()) ? null : recentItems.get(i);
        if (item == null || item.file == null) {
            act.setEnabled(false);/*w  w  w.j  a  v a  2s.  c  o m*/
            String menuTitle = i + "";
            act.putValue(Action.NAME, menuTitle);
            act.putValue(Action.SHORT_DESCRIPTION, null);
        } else {
            act.setEnabled(true);
            String menuTitle = i + " - " + item.file.getName();

            if (!StringUtils.emptyOrNull(item.title))
                menuTitle += " - " + item.title;

            act.putValue(Action.NAME, menuTitle);
            act.putValue(Action.SHORT_DESCRIPTION, item.file.getAbsolutePath());
        }
    }
}

From source file:org.rdv.ui.ConsoleDialog.java

public ConsoleDialog(JDialog owner) {
    super(owner);

    setName("consoleDialog");

    setDefaultCloseOperation(AboutDialog.DISPOSE_ON_CLOSE);

    JPanel container = new JPanel();
    container.setLayout(new BorderLayout());
    container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setContentPane(container);/*from   w  w  w . j  a  va 2s. co  m*/

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    Action disposeAction = new AbstractAction() {
        /** serialized version identifier */
        private static final long serialVersionUID = 4380189911762232261L;

        public void actionPerformed(ActionEvent ae) {
            dispose();
        }
    };

    Action copyAction = new AbstractAction() {

        /** serialized version identifier */
        private static final long serialVersionUID = 2596081241883913660L;

        public void actionPerformed(ActionEvent e) {
            textArea.selectAll();
            textArea.copy();
        }
    };

    //    Action scrollLockAction = new AbstractAction() {
    //      /** serialized version identifier */
    //      private static final long serialVersionUID = -8089076016097529064L;
    //
    //      public void actionPerformed(ActionEvent e) {
    //        //toggle scroll lock
    //        scrollLock_=!scrollLock_;
    //      }
    //    };

    disposeAction.putValue(Action.NAME, "OK");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "dispose");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "dispose");
    actionMap.put("dispose", disposeAction);
    copyAction.putValue(Action.NAME, "Copy");
    actionMap.put("copy", copyAction);
    //    actionMap.put("scroll lock", scrollLockAction);
    //    scrollLockAction.putValue(Action.NAME, "Scroll Lock");

    textArea = new JTextArea();
    textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    textArea.setBackground(Color.WHITE);
    textArea.setForeground(Color.BLACK);
    textArea.setEditable(false);
    textArea.setLineWrap(false);

    Iterator<String> msgIt = messageBuffer.getMessages().iterator();

    //add all the messages in the buffer to this point
    while (msgIt.hasNext()) {
        addMessage(msgIt.next());
    }

    JScrollPane scrollPane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(640, 480));
    container.add(scrollPane, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JButton okButton = new JButton(disposeAction);
    buttonPanel.add(okButton, BorderLayout.EAST);

    JPanel leftBtnsPanel = new JPanel();
    leftBtnsPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.add(leftBtnsPanel, BorderLayout.WEST);

    JButton copyButton = new JButton(copyAction);
    leftBtnsPanel.add(copyButton);

    //    JButton scrollLockButton = new JButton(scrollLockAction);
    //    leftBtnsPanel.add(scrollLockButton);

    container.add(buttonPanel, BorderLayout.SOUTH);

    // inject resources from the properties for this component
    ResourceMap resourceMap = RDV.getInstance().getContext().getResourceMap(getClass());
    resourceMap.injectComponents(this);

    pack();
    okButton.requestFocusInWindow();
    setLocationByPlatform(true);
    setVisible(true);

    messageBuffer.addObserver(this);
}