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

@Override
public void actionPerformed(ActionEvent e) {
    List<File> filesToOpen = new ArrayList<>();

    if (showDialog) {
        List<String> chosenStrings = FileDialogs.getMultipleFiles(frame,
                new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)),
                Collections.singletonList(".bib"), true);
        for (String chosen : chosenStrings) {
            if (chosen != null) {
                filesToOpen.add(new File(chosen));
            }/*  ww w . j  a  v a  2s .c  om*/
        }
    } else {
        LOGGER.info(Action.NAME + " " + e.getActionCommand());
        filesToOpen.add(new File(StringUtil.getCorrectFileName(e.getActionCommand(), "bib")));
    }

    openFiles(filesToOpen, true);
}

From source file:ro.nextreports.designer.action.chart.PreviewChartAction.java

public PreviewChartAction(String chartRunnerType, byte chartGraphicType, String name) {
    this(chartRunnerType, chartGraphicType);
    putValue(Action.NAME, name);
    loaded = false;//from  ww  w  .  j  a  v a 2s.co m
}

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

/**
 * Constructor//  w  w  w  .ja v a 2s. c  o m
 * 
 *@param parent
 *            the "frame" (derived from ptolemy.gui.Top) where the menu is
 *            being added.
 */
public ImportModuleDependenciesAction(TableauFrame parent) {
    super(DISPLAY_NAME);
    if (parent == null) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "ViewManifestAction 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:net.sf.firemox.ui.component.task.TaskAction.java

/**
 * Set a new value to this action. This action will be isplayed as
 * <code>title : <param>htmlValue</param></code>
 * /*from   w ww.  ja v  a 2  s. c o m*/
 * @param htmlValue
 *          the new value to set to this action.
 */
protected void setValue(String htmlValue) {
    putValue(Action.NAME, "<html><b>" + title + " : </b>" + htmlValue);
}

From source file:com.diversityarrays.kdxplore.vistool.VisToolbarFactory.java

static public VisToolToolBar create(final String title, final JComponent comp, final Closure<File> snapshotter,
        final VisToolDataProvider visToolDataProvider, boolean floatable, final String[] imageSuffixes) {
    Window window = GuiUtil.getOwnerWindow(comp);

    boolean anyButtons = false;

    final JCheckBox keepOnTop;

    if (window == null) {
        keepOnTop = null;/*from w  w w  .j av  a  2 s  .c o  m*/
    } else {
        anyButtons = true;
        keepOnTop = new JCheckBox(Msg.OPTION_KEEP_ON_TOP(), true);

        keepOnTop.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                window.setAlwaysOnTop(keepOnTop.isSelected());
            }
        });
        window.setAlwaysOnTop(keepOnTop.isSelected());

        //         buttons.add(keepOnTop);

        final PropertyChangeListener alwaysOnTopListener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                keepOnTop.setSelected(window.isAlwaysOnTop());
            }
        };
        window.addPropertyChangeListener(PROPERTY_ALWAYS_ON_TOP, alwaysOnTopListener);

        window.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                window.removeWindowListener(this);
                window.removePropertyChangeListener(PROPERTY_ALWAYS_ON_TOP, alwaysOnTopListener);
            }
        });
    }

    final JButton cameraButton;
    if (snapshotter == null) {
        cameraButton = null;
    } else {
        Action cameraAction = new AbstractAction(Msg.ACTION_SNAPSHOT()) {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (chooser == null) {
                    chooser = new JFileChooser();
                    chooser.setFileFilter(new FileFilter() {
                        @Override
                        public boolean accept(File f) {
                            if (!f.isFile()) {
                                return true;
                            }
                            String loname = f.getName().toLowerCase();
                            for (String sfx : imageSuffixes) {
                                if (loname.endsWith(sfx)) {
                                    return true;
                                }
                            }
                            return false;
                        }

                        @Override
                        public String getDescription() {
                            return Msg.DESC_IMAGE_FILE();
                        }
                    });
                    chooser.setMultiSelectionEnabled(false);
                    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                }

                if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(comp)) {
                    File file = chooser.getSelectedFile();
                    snapshotter.execute(file);
                }
            }
        };

        ImageIcon icon = loadIcon("camera-24.png"); //$NON-NLS-1$
        if (icon != null) {
            cameraAction.putValue(Action.SMALL_ICON, icon);
            cameraAction.putValue(Action.NAME, null);
        }

        anyButtons = true;
        cameraButton = new JButton(cameraAction);
    }

    final JButton refreshButton;
    if (visToolDataProvider == null) {
        refreshButton = null;
    } else {
        anyButtons = true;

        refreshButton = new JButton(Msg.ACTION_REFRESH());

        ImageIcon icon = loadIcon("refresh-24.png"); //$NON-NLS-1$
        if (icon != null) {
            refreshButton.setIcon(icon);
            // don't remove the name
        }

        refreshButton.setForeground(Color.RED);
        refreshButton.setEnabled(false);

        refreshButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (visToolDataProvider.refreshData()) {
                    refreshButton.setEnabled(false);
                }
            }
        });

        visToolDataProvider.addVisToolDataChangedListener(new VisToolDataChangedListener() {
            @Override
            public void visToolDataChanged(Object source) {
                refreshButton.setEnabled(true);
            }
        });
    }

    VisToolToolBar toolBar = null;

    if (anyButtons) {
        toolBar = new VisToolToolBar(keepOnTop, cameraButton, refreshButton);
        toolBar.setFloatable(floatable);
    }
    return toolBar;

}

From source file:com.meghnasoft.async.AbstractAsynchronousAction.java

/**
 * Constructor, private./*from www .j av  a 2  s. c o m*/
 *
 *
 */
private AbstractAsynchronousAction() {
    //The key used for storing a longer description for the action, could be 
    //used for context-sensitive help.
    putValue(Action.LONG_DESCRIPTION, "Starts an asynchronous task");
    //The key used for storing the name for the action, used for a menu or button.
    //static String
    putValue(Action.NAME, "Start(long)");
    //The key used for storing a short description for the action, 
    //used for tooltip text.
    putValue(Action.SHORT_DESCRIPTION, "Start");
    //Useful constants that can be used as the storage-retreival key when 
    //setting or getting one of this object's properties (text or icon)
    putValue(Action.DEFAULT, "AsynchronousAction");
}

From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java

/**
 * Initialize.//from  w w w.ja  va 2s  . c  o m
 */
public AccountProperties() {
    this.putValue(Action.NAME, "Account Properties...");
    this.putValue(Action.LONG_DESCRIPTION, "Show the properties of an account.");
    this.putValue(Action.SHORT_DESCRIPTION, "Show the properties of an account.");
}

From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java

@SuppressWarnings("serial")
@Override// ww w. j av  a2  s  .c o m
public ButtonPanel createButtonPanel() {
    ButtonPanel buttonPanel = new ButtonPanel();
    JButton closeButton = new JButton();
    JButton detailButton = new JButton();
    detailButton.setMnemonic('D');
    closeButton.setName(OK);
    buttonPanel.addButton(closeButton, ButtonPanel.AFFIRMATIVE_BUTTON);
    buttonPanel.addButton(detailButton, ButtonPanel.OTHER_BUTTON);

    closeButton.setAction(new AbstractAction("Close") {
        @Override
        public void actionPerformed(ActionEvent e) {
            setDialogResult(RESULT_AFFIRMED);
            setVisible(false);
            dispose();
        }
    });

    detailButton.setAction(new AbstractAction("Details >>") {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (_detailsPanel.isVisible()) {
                _detailsPanel.setVisible(false);
                putValue(Action.NAME, "Details <<");
                pack();
            } else {
                _detailsPanel.setVisible(true);
                putValue(Action.NAME, "<< Details");
                pack();
            }
        }
    });

    setDefaultCancelAction(closeButton.getAction());
    setDefaultAction(closeButton.getAction());
    getRootPane().setDefaultButton(closeButton);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    buttonPanel.setSizeConstraint(ButtonPanel.NO_LESS_THAN);
    return buttonPanel;
}

From source file:MenuTest.java

public void actionPerformed(ActionEvent event) {
    System.out.println(getValue(Action.NAME) + " selected.");
}

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

public LoginDialog(JFrame owner) {
    super(owner, true);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setTitle("Login to NEES");

    JPanel container = new JPanel();
    setContentPane(container);/*from   w  w  w .ja v  a2  s . com*/

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

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    headerLabel = new JLabel("Please specify your NEES account information.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    errorLabel = new JLabel();
    errorLabel.setVisible(false);
    errorLabel.setForeground(Color.RED);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.insets = new Insets(10, 10, 0, 10);
    container.add(errorLabel, c);

    c.gridwidth = 1;

    userNameLabel = new JLabel("Username:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(10, 10, 10, 5);
    container.add(userNameLabel, c);

    userNameTextField = new JTextField("", 25);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(10, 0, 10, 10);
    container.add(userNameTextField, c);

    userPasswordLabel = new JLabel("Password:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(userPasswordLabel, c);

    userPasswordField = new JPasswordField(16);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 3;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(0, 0, 10, 10);
    container.add(userPasswordField, c);

    JPanel buttonPanel = new JPanel();

    Action loginAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -5591044023056646223L;

        public void actionPerformed(ActionEvent e) {
            login();
        }
    };
    loginAction.putValue(Action.NAME, "Login");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "login");
    actionMap.put("login", loginAction);
    loginButton = new JButton(loginAction);
    buttonPanel.add(loginButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 6237115705468556255L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    buttonPanel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(buttonPanel, c);

    pack();
    setLocationByPlatform(true);
    setVisible(true);
}