Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

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

Prototype

public AbstractAction(String name) 

Source Link

Document

Creates an Action with the specified name.

Usage

From source file:clipboardplugin.ClipboardPlugin.java

public ActionMenu getContextMenuActions(final Program program) {
    ImageIcon img = createImageIcon("actions", "edit-paste", 16);

    if (mConfigs.length > 1) {
        ContextMenuAction copyToSystem = new ContextMenuAction(
                mLocalizer.ellipsisMsg("copyToSystem", "Copy to system clipboard"));

        ArrayList<AbstractAction> list = new ArrayList<AbstractAction>();

        for (final AbstractPluginProgramFormating config : mConfigs) {
            if (config != null && config.isValid()) {
                final Program[] programs = { program };
                AbstractAction copyAction = new AbstractAction(config.getName()) {
                    public void actionPerformed(ActionEvent e) {
                        copyProgramsToSystem(programs, config);
                    }// w ww. j a v  a  2s . c o  m
                };
                String text = getTextForConfig(programs, config);
                copyAction.setEnabled(text == null || StringUtils.isNotEmpty(text));
                list.add(copyAction);
            }
        }

        copyToSystem.putValue(Action.SMALL_ICON, img);

        return new ActionMenu(copyToSystem, list.toArray(new AbstractAction[list.size()]));
    } else {
        AbstractAction copyToSystem = new AbstractAction(
                mLocalizer.msg("copyToSystem", "Copy to system clipboard")) {
            public void actionPerformed(ActionEvent evt) {
                Program[] list = { program };
                copyProgramsToSystem(list, mConfigs.length != 1 ? DEFAULT_CONFIG : mConfigs[0]);
            }
        };

        copyToSystem.putValue(Action.SMALL_ICON, img);

        return new ActionMenu(copyToSystem);
    }
}

From source file:com.xtructure.xevolution.gui.components.CollectArgsDialog.java

/**
 * Creates a new {@link CollectArgsDialog}
 * //  w  ww.  j  ava 2s . c  om
 * @param frame
 *            the parent JFrame for the new {@link CollectArgsDialog}
 * @param statusBar
 *            the {@link StatusBar} to update (can be null)
 * @param title
 *            the title of the new {@link CollectArgsDialog}
 * @param xOptions
 *            the {@link Collection} of {@link XOption}s for which to
 *            collect user input
 */
public CollectArgsDialog(JFrame frame, final StatusBar statusBar, String title,
        final Collection<XOption<?>> xOptions) {
    super(frame, title, true);

    argComponents = new ArrayList<JComponent>();

    final CollectArgsDialog dialog = this;
    JPanel panel = new JPanel(new GridBagLayout());
    getContentPane().add(panel);
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(3, 3, 3, 3);
    c.fill = GridBagConstraints.BOTH;

    int row = 0;
    for (XOption<?> xOption : xOptions) {
        if (xOption.getName() == null) {
            continue;
        }
        if (xOption.hasArg()) {
            JLabel label = new JLabel(xOption.getName());
            JTextField textField = new JTextField();
            textField.setName(xOption.getOpt());
            textField.setToolTipText(xOption.getDescription());
            argComponents.add(textField);
            c.gridx = 0;
            c.gridy = row;
            panel.add(label, c);
            c.gridx = 1;
            c.gridy = row;
            panel.add(textField, c);
        } else {
            JCheckBox checkBox = new JCheckBox(xOption.getName());
            checkBox.setName(xOption.getOpt());
            checkBox.setToolTipText(xOption.getDescription());
            argComponents.add(checkBox);
            c.gridx = 0;
            c.gridy = row;
            panel.add(checkBox, c);
        }
        row++;
    }

    JPanel buttonPanel = new JPanel();
    c.gridx = 1;
    c.gridy = row;
    panel.add(buttonPanel, c);

    JButton okButton = new JButton(new AbstractAction("OK") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            if (statusBar != null) {
                statusBar.setMessage("building args...");
            }
            ArrayList<String> args = new ArrayList<String>();
            for (JComponent component : argComponents) {
                if (component instanceof JCheckBox) {
                    JCheckBox checkbox = (JCheckBox) component;
                    String opt = checkbox.getName();
                    if (checkbox.isSelected()) {
                        args.add("-" + opt);
                    }
                }
                if (component instanceof JTextField) {
                    JTextField textField = (JTextField) component;
                    String opt = textField.getName();
                    String text = textField.getText().trim();
                    if (!text.isEmpty()) {
                        args.add("-" + opt);
                        args.add("\"" + text + "\"");
                    }
                }
            }
            if (statusBar != null) {
                statusBar.setMessage("parsing args...");
            }
            try {
                Options options = new Options();
                for (XOption<?> xOpt : xOptions) {
                    options.addOption(xOpt);
                }
                XOption.parseArgs(options, args.toArray(new String[0]));
                dialog.success = true;
            } catch (ParseException e1) {
                e1.printStackTrace();
                dialog.success = false;
            }
            if (statusBar != null) {
                statusBar.clearMessage();
            }
        }
    });
    buttonPanel.add(okButton);
    getRootPane().setDefaultButton(okButton);

    buttonPanel.add(new JButton(new AbstractAction("Cancel") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            if (statusBar != null) {
                statusBar.clearMessage();
            }
        }
    }));
    pack();
    setLocationRelativeTo(frame);
    setVisible(true);
}

From source file:org.moeaframework.examples.gp.regression.SymbolicRegressionGUI.java

/**
 * Initialize the components on the GUI.
 *//*from  w  ww . j  a v  a  2s.  c o  m*/
protected void initialize() {
    container = new JPanel(new BorderLayout());

    details = new JTextArea();
    details.setWrapStyleWord(true);
    details.setEditable(false);
    details.setLineWrap(true);

    close = new JButton(new AbstractAction("Close") {

        private static final long serialVersionUID = 2365513341407994400L;

        @Override
        public void actionPerformed(ActionEvent e) {
            isCanceled = true;
            dispose();
        }

    });
}

From source file:org.interreg.docexplore.authoring.AuthoringMenu.java

public AuthoringMenu(final AuthoringToolFrame authoringTool) {
    this.tool = authoringTool;

    this.recent = new LinkedList<String>();
    readRecent();/*from  www .j  av  a 2 s . com*/
    this.file = new JMenu(XMLResourceBundle.getBundledString("generalMenuFile"));
    add(file);

    newItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuNew")) {
        public void actionPerformed(ActionEvent arg0) {
            newFile();
        }
    });
    loadItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuLoad")) {
        public void actionPerformed(ActionEvent arg0) {
            load();
        }
    });
    saveItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSave")) {
        public void actionPerformed(ActionEvent arg0) {
            save();
        }
    });
    saveAsItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSaveAs")) {
        public void actionPerformed(ActionEvent arg0) {
            saveAs();
        }
    });
    exportItem = new JMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("generalMenuExport") + "...") {
                public void actionPerformed(ActionEvent arg0) {
                    GuiUtils.blockUntilComplete(new ProgressRunnable() {
                        public void run() {
                            try {
                                authoringTool.readerExporter.doExport(authoringTool.editor.link);
                            } catch (Exception ex) {
                                ErrorHandler.defaultHandler.submit(ex);
                            }
                        }

                        public float getProgress() {
                            return (float) authoringTool.readerExporter.progress[0];
                        }
                    }, authoringTool.editor);
                }
            });
    webExportItem = new JMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("generalMenuWebExport") + "...") {
                public void actionPerformed(ActionEvent arg0) {
                    GuiUtils.blockUntilComplete(new ProgressRunnable() {
                        public void run() {
                            try {
                                authoringTool.webExporter.doExport(authoringTool.editor.link);
                            } catch (Exception ex) {
                                ErrorHandler.defaultHandler.submit(ex);
                            }
                        }

                        public float getProgress() {
                            return (authoringTool.webExporter.copyComplete ? .5f : 0f)
                                    + (float) (.5 * authoringTool.webExporter.progress[0]);
                        }
                    }, authoringTool.editor);
                }
            });
    //      webExportItem = new JMenuItem(new AbstractAction("Web export") {public void actionPerformed(ActionEvent arg0)
    //      {
    //         GuiUtils.blockUntilComplete(new Runnable() {public void run()
    //         {
    //            try 
    //            {
    //               new WebStaticExporter().doExport(authoringTool.editor.link.getBook(authoringTool.editor.link.getLink().getAllBookIds().get(0)));
    //            }
    //            catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex);}
    //         }}, authoringTool.editor);
    //      }});
    //      webExportItem.setEnabled(false);
    quitItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuQuit")) {
        public void actionPerformed(ActionEvent arg0) {
            authoringTool.quit();
        }
    });
    buildFileMenu();

    JMenu edit = new JMenu(XMLResourceBundle.getBundledString("generalMenuEdit"));
    this.undoItem = new JMenuItem();
    undoItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                authoringTool.historyManager.undo();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    });
    edit.add(undoItem);
    this.redoItem = new JMenuItem();
    redoItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                authoringTool.historyManager.redo();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    });
    edit.add(redoItem);
    JMenuItem viewHistory = new JMenuItem(XMLResourceBundle.getBundledString("generalMenuEditViewHistory"));
    viewHistory.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            authoringTool.historyDialog.setVisible(true);
        }
    });
    edit.add(viewHistory);

    edit.addSeparator();

    edit.add(new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("fixChars")) {
        public void actionPerformed(ActionEvent arg0) {
            Object res = JOptionPane.showInputDialog(tool, XMLResourceBundle.getBundledString("fixCharsMsg"),
                    XMLResourceBundle.getBundledString("fixChars"), JOptionPane.QUESTION_MESSAGE, null,
                    new Object[] { XMLResourceBundle.getBundledString("fixCharsWin"),
                            XMLResourceBundle.getBundledString("fixCharsMac") },
                    XMLResourceBundle.getBundledString("fixCharsWin"));
            if (res == null)
                return;
            try {
                convertPresentation(tool.defaultFile,
                        res.equals(XMLResourceBundle.getBundledString("fixCharsWin")) ? "ISO-8859-1"
                                : "x-MacRoman");
            } catch (Exception e) {
                ErrorHandler.defaultHandler.submit(e);
            }
            try {
                tool.editor.reset();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }));

    //TODO: remove!
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               if (regions.size() > 2)
    //               {
    //                  Region highest = null;
    //                  int max = -1;
    //                  for (Region region : regions)
    //                     for (Point point : region.getOutline())
    //                        if (max < 0 || point.y < max)
    //                           {max = point.y; highest = region;}
    //                  Region middle = null;
    //                  max = -1;
    //                  for (Region region : regions)
    //                     if (region != highest)
    //                        for (Point point : region.getOutline())
    //                           if (max < 0 || point.y < max)
    //                              {max = point.y; middle = region;}
    //                  if (regions.size() > 3)
    //                  {
    //                     max = -1;
    //                     Region newMiddle = null;
    //                     for (Region region : regions)
    //                        if (region != highest && region != middle)
    //                           for (Point point : region.getOutline())
    //                              if (max < 0 || point.y < max)
    //                                 {max = point.y; newMiddle = region;}
    //                     middle = newMiddle;
    //                  }
    //                  MetaDataKey display = book.getLink().getKey("display", "");
    //                  for (Map.Entry<MetaDataKey, List<MetaData>> entry : highest.getMetaData().entrySet())
    //                     for (MetaData md : entry.getValue())
    //                        if (md.getType().equals(MetaData.textType))
    //                        {
    //                           String val = "<b>"+md.getString()+"</b>\n";
    //                           for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet())
    //                              for (MetaData md2 : entry2.getValue())
    //                                 if (md2.getType().equals(MetaData.textType) && TextElement.getStyle(md, tool.styleManager) == TextElement.getStyle(md2, tool.styleManager))
    //                                    val = val+"\n"+md2.getString();
    //                           md.setString(val);
    //                        }
    //                  boolean hasImage = false;
    //                  for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet())
    //                     for (MetaData md2 : entry2.getValue())
    //                        if (md2.getType().equals(MetaData.imageType))
    //                        {
    //                           MetaData imageMd = new MetaData(book.getLink(), display, md2.getType(), md2.getValue());
    //                           if (!hasImage)
    //                              BookImporter.insert(imageMd, highest, 0);
    //                           else BookImporter.insert(imageMd, highest, BookImporter.getHighestRank(highest)+1);
    //                           hasImage = true;
    //                        }
    //                  page.removeRegion(middle);
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            MetaDataKey display = book.getLink().getKey("display", "");
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               for (Region region : regions)
    //               {
    //                  List<MetaData> mds = region.getMetaDataListForKey(display);
    //                     for (MetaData md : mds)
    //                        if (md.getType().equals(MetaData.textType))
    //                        {
    //                           String val = md.getString().trim();
    //                           if (!val.startsWith("<i>") || !val.endsWith("</i>"))
    //                              continue;
    //                           TextElement.getStyleMD(md).setString("4");
    //                           md.setString(val.substring(3, val.length()-4));
    //                           System.out.println(md.getString());
    //                        }
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            MetaDataKey display = book.getLink().getKey("display", "");
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               for (Region region : regions)
    //               {
    //                  int max = BookImporter.getHighestRank(region);
    //                  for (int i=0;i<max;i++)
    //                  {
    //                     MetaData md1 = BookImporter.getAtRank(region, i);
    //                     if (md1 == null || !md1.getType().equals(MetaData.textType))
    //                        continue;
    //                     MetaData style1 = TextElement.getStyleMD(md1);
    //                     if (!style1.getString().equals("0"))
    //                        continue;
    //                     MetaData md2 = BookImporter.getAtRank(region, i+1);
    //                     if (md2 == null || !md2.getType().equals(MetaData.textType))
    //                        continue;
    //                     MetaData style2 = TextElement.getStyleMD(md2);
    //                     if (!style2.getString().equals("1"))
    //                        continue;
    //                     BookImporter.setRank(md1, i+1);
    //                     BookImporter.setRank(md2, i);
    //                     i++;
    //                  }
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            MetaDataKey mini = book.getLink().getOrCreateKey("mini", "");
    //            MetaDataKey dim = book.getLink().getOrCreateKey("dimension", "");
    //            int lastPage = book.getLastPageNumber();
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               List<MetaData> mds = page.getMetaDataListForKey(mini);
    //               if (mds != null)
    //                  for (MetaData md : mds)
    //                     page.removeMetaData(md);
    //               mds = page.getMetaDataListForKey(dim);
    //               if (mds != null)
    //                  for (MetaData md : mds)
    //                     page.removeMetaData(md);
    //               DocExploreDataLink.getImageDimension(page, true);
    //               DocExploreDataLink.getImageMini(page, false);
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));

    add(edit);

    JMenu view = new JMenu(XMLResourceBundle.getBundledString("generalMenuView"));
    add(view);

    JMenuItem styles = new JMenuItem(XMLResourceBundle.getBundledString("styleEdit") + "...",
            ImageUtils.getIcon("pencil-24x24.png"));
    styles.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            authoringTool.styleManager.styleDialog.setVisible(true);
        }
    });
    view.add(styles);

    helpToggle = new JCheckBoxMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("viewHelpToggle")) {
                public void actionPerformed(ActionEvent arg0) {
                    authoringTool.displayHelp = helpToggle.isSelected();
                    authoringTool.repaint();
                }
            });
    helpToggle.setSelected(tool.startup.showHelp);
    view.add(helpToggle);

    JMenu helpMenu = new JMenu(XMLResourceBundle.getString("management-lrb", "generalMenuHelp"));
    if (Desktop.isDesktopSupported()) {
        final Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            helpMenu.add(new AbstractAction(
                    XMLResourceBundle.getString("management-lrb", "generalMenuHelpContents")) {
                public void actionPerformed(ActionEvent e) {
                    try {
                        File doc = new File(DocExploreTool.getExecutableDir(), "MMT documentation.htm");
                        desktop.open(doc);
                    } catch (Exception ex) {
                        ErrorHandler.defaultHandler.submit(ex, true);
                    }
                }
            });
            helpMenu.add(new AbstractAction(
                    XMLResourceBundle.getString("management-lrb", "generalMenuHelpWebsite")) {
                public void actionPerformed(ActionEvent e) {
                    try {
                        File link = new File(DocExploreTool.getExecutableDir(), "website.url");
                        desktop.open(link);
                    } catch (Exception ex) {
                        ErrorHandler.defaultHandler.submit(ex, true);
                    }
                }
            });
        }
    }
    helpMenu.add(new AbstractAction(XMLResourceBundle.getString("management-lrb", "generalMenuHelpAbout")) {
        public void actionPerformed(ActionEvent e) {
            final JDialog splash = new JDialog(tool, true);
            splash.setLayout(new BorderLayout());
            SplashScreen screen = new SplashScreen("logoAT.png");
            splash.add(screen, BorderLayout.NORTH);
            screen.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    splash.setVisible(false);
                }
            });
            splash.setUndecorated(true);
            screen.setText(
                    "<html>DocExplore 2009-2014" + "<br/>Released under the CeCILL v2.1 license" + "</html>");
            splash.pack();
            splash.setAlwaysOnTop(true);
            GuiUtils.centerOnScreen(splash);
            splash.setVisible(true);
        }
    });
    add(helpMenu);

    historyChanged(authoringTool.historyManager);
    authoringTool.historyManager.addHistoryListener(this);
}

From source file:org.accretegb.modules.phenotype.PhenotypeInfoPanel.java

/**
 * populates parameter names from database
 *///  w  w w. j a  v a 2 s .c om
public void populateParameterNames() {
    parameterName = new JButton();
    parametersCheckBoxes = new ArrayList<JCheckBox>();
    List<String> parameters = new ArrayList<String>();
    List<MeasurementParameter> results = MeasurementParameterDAO.getInstance().findAll();
    for (MeasurementParameter obj : results) {
        parameters.add(obj.getParameterName());
        parameter_id.put(obj.getParameterName(), String.valueOf(obj.getMeasurementParameterId()));
    }
    final JPopupMenu columnsPopupMenu = new JPopupMenu();
    final JCheckBox[] columnNameCheckBox = new JCheckBox[parameters.size()];
    JPanel columnsPopupPanel = new JPanel(new MigLayout("insets 0, gap 0"));
    JScrollPane scrollPane = new JScrollPane(columnsPopupPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    for (int columnCounter = 0; columnCounter < columnNameCheckBox.length; ++columnCounter) {
        columnNameCheckBox[columnCounter] = new JCheckBox(parameters.get(columnCounter));
        parametersCheckBoxes.add(columnNameCheckBox[columnCounter]);
        columnsPopupPanel.add(columnNameCheckBox[columnCounter], "wrap");
    }
    scrollPane.setPreferredSize(new Dimension(150, 300));

    columnsPopupMenu.add(scrollPane);
    parameterName.setAction(new AbstractAction("select") {
        public void actionPerformed(ActionEvent e) {
            columnsPopupMenu.show(parameterName, 0, parameterName.getHeight());
        }
    });
}

From source file:com.simplexrepaginator.RepaginateFrame.java

protected JMenuBar createMenuBar() {
    JMenuBar mb = new JMenuBar();
    JMenu m;/*w  w  w .ja  v a 2  s  .  c o m*/

    m = new JMenu("File");
    m.add(new AbstractAction("Select Input") {
        @Override
        public void actionPerformed(ActionEvent e) {
            input.doClick();
        }
    });
    m.add(new AbstractAction("Select Output") {
        @Override
        public void actionPerformed(ActionEvent e) {
            output.doClick();
        }
    });
    m.add(new UpdateCheckerAction());
    m.add(new AbstractAction("Exit") {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            dispose();
        }
    });
    mb.add(m);

    m = new JMenu("Help");
    m.add(new AbstractAction("Website") {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                URL url = new URL("http://www.simplexrepaginator.com/");
                Desktop.getDesktop().browse(url.toURI());
            } catch (IOException ioe) {
            } catch (URISyntaxException urise) {
            }
        }
    });
    m.add(new AbstractAction("About") {
        @Override
        public void actionPerformed(ActionEvent e) {
            String license;
            try {
                license = IOUtils.toString(RepaginateFrame.class.getResource("LICENSE.txt"));
            } catch (IOException ioe) {
                license = "An error occured reading the license file:\n" + ioe;
            }
            JOptionPane.showMessageDialog(RepaginateFrame.this, license);
        }
    });
    mb.add(m);

    return mb;
}

From source file:com.projity.dialog.XbsDependencyDialog.java

public ButtonPanel createButtonPanel() {
    AbstractAction action = new AbstractAction(Messages.getString("Text.Remove")) {
        public void actionPerformed(ActionEvent e) {
            delete();/*  ww w  .  j  av  a  2 s  .c o  m*/
        }
    };
    removeButton = new JButton(action);

    createOkCancelButtons();
    ButtonPanel buttonPanel = new ButtonPanel();
    buttonPanel.addButton(removeButton);
    //buttonPanel.addButton(ok);
    buttonPanel.addButton(cancel);
    return buttonPanel;
}

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

@SuppressWarnings("serial")
@Override// www .  j  a  va2s  . 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:CubaHSQLDBServer.java

private void addCopyPopup(final JTextArea source) {
    final JPopupMenu popup = new JPopupMenu();
    popup.add(new AbstractAction("Copy to clipboard") {
        @Override//from w  ww  .  ja v  a  2s  . com
        public void actionPerformed(ActionEvent e) {
            StringSelection contents = new StringSelection(source.getText());
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, contents);
        }
    });
    source.add(popup);
    source.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show(source, e.getX(), e.getY());
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show(source, e.getX(), e.getY());
            }
        }
    });
}

From source file:org.openconcerto.erp.panel.ITreeSelection.java

public void mousePressed(MouseEvent e) {

    TreePath path = this.getSelectionPath();
    if (path != null) {
        Object o = path.getLastPathComponent();

        int id = 1;

        if (e.getButton() == MouseEvent.BUTTON3) {

            final int idSelect = getSelectedID();

            // Ajouter, supprimer, modifier un lment dans l'arbre

            JPopupMenu menu = new JPopupMenu();
            menu.add(new AbstractAction("Ajouter un lment") {
                public void actionPerformed(ActionEvent e) {
                    addElement(idSelect);
                }/*from  w  ww . ja  v  a 2  s. c o  m*/
            });

            if (idSelect > 1) {
                menu.add(new AbstractAction("Modifier") {
                    public void actionPerformed(ActionEvent e) {
                        modifyElement(idSelect);
                    }
                });

                menu.add(new AbstractAction("Supprimer") {
                    public void actionPerformed(ActionEvent e) {
                        removeElement(idSelect);
                    }
                });
            }
            menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
        }
    }
}