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() 

Source Link

Document

Creates an Action .

Usage

From source file:captureplugin.CapturePlugin.java

public ActionMenu getButtonAction() {
    AbstractAction action = new AbstractAction() {

        public void actionPerformed(ActionEvent evt) {
            showDialog();/* w ww. ja v a2 s  .  c  om*/
        }
    };
    action.putValue(Action.NAME, mLocalizer.msg("CapturePlugin", "Capture Plugin"));
    action.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16));
    action.putValue(BIG_ICON, createImageIcon("mimetypes", "video-x-generic", 22));

    return new ActionMenu(action);
}

From source file:javazoom.jlgui.player.amp.StandalonePlayer.java

/**
 * Install keyboard shortcuts./*w  ww  . j a v  a2s.  c om*/
 */
public void setKeyBoardShortcut() {
    KeyStroke jKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false);
    KeyStroke ctrlPKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK, false);
    KeyStroke altSKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.ALT_MASK, false);
    KeyStroke vKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false);
    String searchID = "TAGSEARCH";
    String preferenceID = "PREFERENCES";
    String skinbrowserID = "SKINBROWSER";
    String stopplayerID = "STOPPLAYER";
    Action searchAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processJumpToFile(e.getModifiers());
        }
    };
    Action preferencesAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processPreferences(e.getModifiers());
        }
    };
    Action skinbrowserAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processSkinBrowser(e.getModifiers());
        }
    };
    Action stopplayerAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processStop(MouseEvent.BUTTON1_MASK);
        }
    };
    setKeyboardAction(searchID, jKeyStroke, searchAction);
    setKeyboardAction(preferenceID, ctrlPKeyStroke, preferencesAction);
    setKeyboardAction(skinbrowserID, altSKeyStroke, skinbrowserAction);
    setKeyboardAction(stopplayerID, vKeyStroke, stopplayerAction);
}

From source file:org.kse.gui.dialogs.sign.DSignMidlet.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;/*from w  ww  .ja  v a 2  s.  co m*/
    gbcLbl.gridwidth = 1;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;
    gbcLbl.weightx = 0;

    GridBagConstraints gbcCtrl = new GridBagConstraints();
    gbcCtrl.gridx = 1;
    gbcCtrl.gridwidth = 1;
    gbcCtrl.gridheight = 1;
    gbcCtrl.insets = new Insets(5, 5, 5, 5);
    gbcCtrl.anchor = GridBagConstraints.WEST;
    gbcCtrl.fill = GridBagConstraints.NONE;
    gbcCtrl.weightx = 1;

    GridBagConstraints gbcBrws = new GridBagConstraints();
    gbcBrws.gridx = 2;
    gbcBrws.gridwidth = 1;
    gbcBrws.gridheight = 1;
    gbcBrws.insets = new Insets(5, 5, 5, 5);
    gbcBrws.anchor = GridBagConstraints.WEST;
    gbcBrws.fill = GridBagConstraints.NONE;
    gbcBrws.weightx = 1;

    jlInputJad = new JLabel(res.getString("DSignMidlet.jlInputJad.text"));
    GridBagConstraints gbc_jlInputJad = (GridBagConstraints) gbcLbl.clone();
    gbc_jlInputJad.gridy = 0;

    jtfInputJad = new JTextField(30);
    jtfInputJad.setCaretPosition(0);
    jtfInputJad.setToolTipText(res.getString("DSignMidlet.jtfInputJad.tooltip"));
    GridBagConstraints gbc_jtfInputJad = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfInputJad.gridy = 0;

    jbInputJadBrowse = new JButton(res.getString("DSignMidlet.jbInputJadBrowse.text"));
    PlatformUtil.setMnemonic(jbInputJadBrowse,
            res.getString("DSignMidlet.jbInputJadBrowse.mnemonic").charAt(0));
    jbInputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbInputJadBrowse.tooltip"));
    jbInputJadBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                inputJadBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbInputJadBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbInputJadBrowse.gridy = 0;

    jlSignDirectly = new JLabel(res.getString("DSignMidlet.jlSignDirectly.text"));
    GridBagConstraints gbc_jlSignDirectly = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSignDirectly.gridy = 1;

    jcbSignDirectly = new JCheckBox();
    jcbSignDirectly.setSelected(true);
    jcbSignDirectly.setToolTipText(res.getString("DSignMidlet.jcbSignDirectly.tooltip"));
    GridBagConstraints gbc_jcbSignDirectly = (GridBagConstraints) gbcCtrl.clone();
    gbc_jcbSignDirectly.gridy = 1;

    jcbSignDirectly.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            jtfOutputJad.setEnabled(!jcbSignDirectly.isSelected());
            jbOutputJadBrowse.setEnabled(!jcbSignDirectly.isSelected());
        }
    });

    jlOutputJad = new JLabel(res.getString("DSignMidlet.jlOutputJad.text"));
    GridBagConstraints gbc_jlOutputJad = (GridBagConstraints) gbcLbl.clone();
    gbc_jlOutputJad.gridy = 2;

    jtfOutputJad = new JTextField(30);
    jtfOutputJad.setEnabled(false);
    jtfOutputJad.setCaretPosition(0);
    jtfOutputJad.setToolTipText(res.getString("DSignMidlet.jtfOutputJad.tooltip"));
    GridBagConstraints gbc_jtfOutputJad = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfOutputJad.gridy = 2;

    jbOutputJadBrowse = new JButton(res.getString("DSignMidlet.jbOutputJadBrowse.text"));
    PlatformUtil.setMnemonic(jbOutputJadBrowse,
            res.getString("DSignMidlet.jbOutputJadBrowse.mnemonic").charAt(0));
    jbOutputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbOutputJadBrowse.tooltip"));
    jbOutputJadBrowse.setEnabled(false);
    jbOutputJadBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                outputJadBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbOutputJadBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbOutputJadBrowse.gridy = 2;

    jlJar = new JLabel(res.getString("DSignMidlet.jlJar.text"));
    GridBagConstraints gbc_jlJar = (GridBagConstraints) gbcLbl.clone();
    gbc_jlJar.gridy = 3;

    jtfJar = new JTextField(30);
    jtfJar.setCaretPosition(0);
    jtfJar.setToolTipText(res.getString("DSignMidlet.jtfJar.tooltip"));
    GridBagConstraints gbc_jtfJar = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfJar.gridy = 3;

    jbJarBrowse = new JButton(res.getString("DSignMidlet.jbJarBrowse.text"));
    PlatformUtil.setMnemonic(jbJarBrowse, res.getString("DSignMidlet.jbJarBrowse.mnemonic").charAt(0));
    jbJarBrowse.setToolTipText(res.getString("DSignMidlet.jbJarBrowse.tooltip"));
    jbJarBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                jarBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbJarBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbJarBrowse.gridy = 3;

    jpOptions = new JPanel(new GridBagLayout());
    jpOptions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()));

    jpOptions.add(jlInputJad, gbc_jlInputJad);
    jpOptions.add(jtfInputJad, gbc_jtfInputJad);
    jpOptions.add(jbInputJadBrowse, gbc_jbInputJadBrowse);
    jpOptions.add(jlSignDirectly, gbc_jlSignDirectly);
    jpOptions.add(jcbSignDirectly, gbc_jcbSignDirectly);
    jpOptions.add(jlOutputJad, gbc_jlOutputJad);
    jpOptions.add(jtfOutputJad, gbc_jtfOutputJad);
    jpOptions.add(jbOutputJadBrowse, gbc_jbOutputJadBrowse);
    jpOptions.add(jlJar, gbc_jlJar);
    jpOptions.add(jtfJar, gbc_jtfJar);
    jpOptions.add(jbJarBrowse, gbc_jbJarBrowse);

    jbOK = new JButton(res.getString("DSignMidlet.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });

    jbCancel = new JButton(res.getString("DSignMidlet.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpOptions, BorderLayout.NORTH);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setResizable(false);

    getRootPane().setDefaultButton(jbOK);

    pack();
}

From source file:de.codesourcery.eve.skills.ui.components.impl.RefiningComponent.java

@Override
protected JPanel createPanel() {

    refinedItemsTable.setRowSorter(refinedItemsModel.getRowSorter());
    refinedItemsTable.setFillsViewportHeight(true);

    refinedItemsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override/*from   w  w  w. j av  a 2 s . co m*/
        public void valueChanged(ListSelectionEvent e) {
            updateSelectedTotalValues(getSelectedRows(refinedItemsTable));
        }
    });

    final TableCellRenderer refinedItemsRenderer = new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

            setHorizontalAlignment(JLabel.TRAILING);

            if (value instanceof ISKAmount) {
                setText(AmountHelper.formatISKAmount((ISKAmount) value) + " ISK");
            } else {
                setText("0.0 ISK");
            }

            return this;
        }
    };

    FixedBooleanTableCellRenderer.attach(refinedItemsTable);
    refinedItemsTable.setDefaultRenderer(ISKAmount.class, refinedItemsRenderer);

    refiningResultsTable.setRowSorter(refiningResultsModel.getRowSorter());
    refiningResultsTable.setFillsViewportHeight(true);

    final PopupMenuBuilder menuBuilder = new PopupMenuBuilder();

    menuBuilder.addItem("Copy to clipboard (text)", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            putRefiningResultsOnClipboard();
        }

        @Override
        public boolean isEnabled() {
            return refiningResultsModel.getRowCount() > 0;
        }
    });

    menuBuilder.attach(refiningResultsTable);

    final PopupMenuBuilder menuBuilder2 = new PopupMenuBuilder();

    menuBuilder2.addItem("Remove", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final int[] viewRows = refinedItemsTable.getSelectedRows();

            final int[] modelRows = new int[viewRows.length];
            for (int i = 0; i < viewRows.length; i++) {
                modelRows[i] = refinedItemsTable.convertRowIndexToModel(viewRows[i]);
            }
            refinedItemsModel.removeRows(modelRows);
        }

        @Override
        public boolean isEnabled() {
            return !ArrayUtils.isEmpty(refinedItemsTable.getSelectedRows());
        }
    });

    menuBuilder2.attach(refinedItemsTable);

    refiningResultsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateSelectedTotalValues(getSelectedRows(refiningResultsTable));
        }
    });

    final DefaultTableCellRenderer resultsRenderer = new DefaultTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

            if (column != 0) {
                setHorizontalAlignment(JLabel.TRAILING);
            } else {
                setHorizontalAlignment(JLabel.LEADING);
            }

            if (value instanceof ISKAmount) {
                setText(AmountHelper.formatISKAmount((ISKAmount) value) + " ISK");
            } else if (value == null) {
                setText("<price unavailable>");
            }
            return this;
        }
    };

    refiningResultsTable.setDefaultRenderer(String.class, resultsRenderer);
    refiningResultsTable.setDefaultRenderer(Integer.class, resultsRenderer);
    refiningResultsTable.setDefaultRenderer(ISKAmount.class, resultsRenderer);

    final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.VERTICAL_SPLIT,
            new JScrollPane(refinedItemsTable), new JScrollPane(refiningResultsTable));

    splitPane.setDividerLocation(0.3);

    /*
     * Button panel
     */

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());

    buttonPanel.add(addButton, constraints(0, 0).anchorWest().useRelativeWidth().noResizing().end());

    addButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ItemChooserComponent comp = new ItemChooserComponent(
                    ItemChooserComponent.SelectionMode.MULTIPLE_SELECTION);

            comp.setModal(true);
            ComponentWrapper.wrapComponent("Add item to refine", comp).setVisible(true);

            if (!comp.wasCancelled() && !comp.getSelectedItems().isEmpty()) {
                final List<ItemWithQuantity> currentItems = refinedItemsModel.getItemsWithQuantity();
                for (InventoryType t : comp.getSelectedItems()) {
                    currentItems.add(new ItemWithQuantity(t, 1));
                }
                refinedItemsModel.setItemsToRefine(currentItems);
            }
        }
    });

    /*
     * Create result panel.
     */
    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    panel.add(createSelectionPanel(), constraints(0, 0).weightX(0.8).useRelativeWidth().anchorSouth().weightY(0)
            .resizeHorizontally().end());
    panel.add(selectedISKValue.getPanel(),
            constraints(1, 0).weightX(0.2).weightY(0).resizeHorizontally().anchorNorth().end());

    panel.add(buttonPanel, constraints(0, 1).weightX(0.8).width(1).weightY(0).anchorWest().end());
    panel.add(selectedVolume.getPanel(), constraints(1, 1).weightX(0.2).width(1).weightY(0).anchorWest().end());

    panel.add(splitPane, constraints(0, 2).width(2).resizeBoth().end());

    this.refiningResultsModel.update();

    return panel;
}

From source file:net.sf.jabref.openoffice.OpenOfficePanel.java

private void initPanel() {

    useDefaultAuthoryearStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE);
    useDefaultNumericalStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE);

    connect.addActionListener(e -> connect(true));
    manualConnect.addActionListener(e -> connect(false));

    selectDocument.setToolTipText(Localization.lang("Select which open Writer document to work on"));
    selectDocument.addActionListener(e -> {

        try {//from   w  ww.ja va  2s .c o  m
            ooBase.selectDocument();
            frame.output(Localization.lang("Connected to document") + ": "
                    + ooBase.getCurrentDocumentTitle().orElse(""));
        } catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException
                | NoSuchElementException | NoDocumentException ex) {
            JOptionPane.showMessageDialog(frame, ex.getMessage(), Localization.lang("Error"),
                    JOptionPane.ERROR_MESSAGE);
            LOGGER.warn("Problem connecting", ex);
        }

    });

    setStyleFile.addActionListener(e -> {

        if (styleDialog == null) {
            styleDialog = new StyleSelectDialog(frame, styleFile);
        }
        styleDialog.setVisible(true);
        if (styleDialog.isOkPressed()) {
            useDefaultAuthoryearStyle = Globals.prefs
                    .getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE);
            useDefaultNumericalStyle = Globals.prefs
                    .getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE);
            styleFile = Globals.prefs.get(JabRefPreferences.OO_BIBLIOGRAPHY_STYLE_FILE);
            try {
                readStyleFile();
            } catch (IOException ex) {
                LOGGER.warn("Could not read style file", ex);
            }
        }

    });

    pushEntries.setToolTipText(Localization.lang("Cite selected entries between parenthesis"));
    pushEntries.addActionListener(e -> pushEntries(true, true, false));
    pushEntriesInt.setToolTipText(Localization.lang("Cite selected entries with in-text citation"));
    pushEntriesInt.addActionListener(e -> pushEntries(false, true, false));
    pushEntriesEmpty.setToolTipText(
            Localization.lang("Insert a citation without text (the entry will appear in the reference list)"));
    pushEntriesEmpty.addActionListener(e -> pushEntries(false, false, false));
    pushEntriesAdvanced.setToolTipText(Localization.lang("Cite selected entries with extra information"));
    pushEntriesAdvanced.addActionListener(e -> pushEntries(false, true, true));

    update.setToolTipText(Localization.lang("Ensure that the bibliography is up-to-date"));
    Action updateAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (style == null) {
                    readStyleFile();
                } else {
                    style.ensureUpToDate();
                }

                ooBase.updateSortedReferenceMarks();

                List<BibDatabase> databases = getBaseList();
                List<String> unresolvedKeys = ooBase.refreshCiteMarkers(databases, style);
                ooBase.rebuildBibTextSection(databases, style);
                if (!unresolvedKeys.isEmpty()) {
                    JOptionPane.showMessageDialog(frame, Localization.lang(
                            "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
                            unresolvedKeys.get(0)), Localization.lang("Unable to synchronize bibliography"),
                            JOptionPane.ERROR_MESSAGE);
                }
            } catch (UndefinedCharacterFormatException ex) {
                reportUndefinedCharacterFormat(ex);
            } catch (UndefinedParagraphFormatException ex) {
                reportUndefinedParagraphFormat(ex);
            } catch (ConnectionLostException ex) {
                showConnectionLostErrorMessage();
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(frame,
                        Localization.lang(
                                "You must select either a valid style file, or use one of the default styles."),
                        Localization.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE);
                LOGGER.warn("Problem with style file", ex);
                return;
            } catch (BibEntryNotFoundException ex) {
                JOptionPane.showMessageDialog(frame, Localization.lang(
                        "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
                        ex.getBibtexKey()), Localization.lang("Unable to synchronize bibliography"),
                        JOptionPane.ERROR_MESSAGE);
                LOGGER.debug("BibEntry not found", ex);
            } catch (Exception ex) {
                LOGGER.warn("Could not update bibliography", ex);
            }
        }
    };
    update.addActionListener(updateAction);

    merge.setToolTipText(Localization.lang("Combine pairs of citations that are separated by spaces only"));
    merge.addActionListener(e -> {
        try {
            ooBase.combineCiteMarkers(getBaseList(), style);
        } catch (UndefinedCharacterFormatException ex) {
            reportUndefinedCharacterFormat(ex);
        } catch (Exception ex) {
            LOGGER.warn("Problem combining cite markers", ex);
        }

    });
    settingsB.addActionListener(e -> showSettingsPopup());
    manageCitations.addActionListener(e -> {
        try {
            CitationManager cm = new CitationManager(frame, ooBase);
            cm.showDialog();
        } catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) {
            LOGGER.warn("Problem showing citation manager", ex);
        }

    });

    selectDocument.setEnabled(false);
    pushEntries.setEnabled(false);
    pushEntriesInt.setEnabled(false);
    pushEntriesEmpty.setEnabled(false);
    pushEntriesAdvanced.setEnabled(false);
    update.setEnabled(false);
    merge.setEnabled(false);
    manageCitations.setEnabled(false);
    diag = new JDialog((JFrame) null, "OpenOffice panel", false);

    DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:pref:grow",
            //"p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu"));
            "p,p,p,p,p,p,p,p,p,p"));

    //ButtonBarBuilder bb = new ButtonBarBuilder();
    DefaultFormBuilder bb = new DefaultFormBuilder(
            new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, "
                    + "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", ""));
    bb.append(connect);
    bb.append(manualConnect);
    bb.append(selectDocument);
    bb.append(update);
    bb.append(help);
    b.append(bb.getPanel());
    b.append(setStyleFile);
    b.append(pushEntries);
    b.append(pushEntriesInt);
    b.append(pushEntriesAdvanced);
    b.append(pushEntriesEmpty);
    b.append(merge);
    b.append(manageCitations);
    b.append(settingsB);

    JPanel content = new JPanel();
    comp.setContentContainer(content);
    content.setLayout(new BorderLayout());
    content.add(b.getPanel(), BorderLayout.CENTER);

    frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(Globals.getKeyPrefs().getKey(KeyBinding.REFRESH_OO), "Refresh OO");
    frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction);

}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.ApproximationSetViewer.java

/**
 * Initializes this window.  This method is invoked in the constructor, and
 * should not be invoked again./*from w ww.j a  v a2s.c om*/
 */
protected void initialize() {
    //initialize the NFE slider
    int minimumNFE = Integer.MAX_VALUE;
    int maximumNFE = Integer.MIN_VALUE;

    for (Accumulator accumulator : accumulators) {
        minimumNFE = Math.min(minimumNFE, (Integer) accumulator.get("NFE", 0));
        maximumNFE = Math.max(maximumNFE, (Integer) accumulator.get("NFE", accumulator.size("NFE") - 1));
    }

    slider = new JSlider(minimumNFE, maximumNFE, minimumNFE);
    slider.setPaintTicks(true);
    slider.setMinorTickSpacing(100);
    slider.setMajorTickSpacing(1000);
    slider.addChangeListener(this);

    //initializes the options available for axis plotting
    Solution solution = (Solution) ((List<?>) accumulators.get(0).get("Approximation Set", 0)).get(0);
    Vector<String> objectives = new Vector<String>();

    for (int i = 0; i < solution.getNumberOfObjectives(); i++) {
        objectives.add(localization.getString("text.objective", i + 1));
    }

    for (int i = 0; i < solution.getNumberOfConstraints(); i++) {
        objectives.add(localization.getString("text.constraint", i + 1));
    }

    for (int i = 0; i < solution.getNumberOfVariables(); i++) {
        objectives.add(localization.getString("text.variable", i + 1));
    }

    xAxisSelection = new JComboBox(objectives);
    yAxisSelection = new JComboBox(objectives);

    xAxisSelection.setSelectedIndex(0);
    yAxisSelection.setSelectedIndex(1);

    xAxisSelection.addActionListener(this);
    yAxisSelection.addActionListener(this);

    //initialize the reference set bounds
    initializeReferenceSetBounds();

    //initialize plotting controls
    useInitialBounds = new JRadioButton(localization.getString("action.useInitialBounds.name"));
    useReferenceSetBounds = new JRadioButton(localization.getString("action.useReferenceSetBounds.name"));
    useDynamicBounds = new JRadioButton(localization.getString("action.useDynamicBounds.name"));
    useZoomBounds = new JRadioButton(localization.getString("action.useZoom.name"));

    useInitialBounds.setToolTipText(localization.getString("action.useInitialBounds.description"));
    useReferenceSetBounds.setToolTipText(localization.getString("action.useReferenceSetBounds.description"));
    useDynamicBounds.setToolTipText(localization.getString("action.useDynamicBounds.description"));
    useZoomBounds.setToolTipText(localization.getString("action.useZoom.description"));

    ButtonGroup rangeButtonGroup = new ButtonGroup();
    rangeButtonGroup.add(useInitialBounds);
    rangeButtonGroup.add(useReferenceSetBounds);
    rangeButtonGroup.add(useDynamicBounds);
    rangeButtonGroup.add(useZoomBounds);

    if (referenceSet == null) {
        useReferenceSetBounds.setEnabled(false);
    }

    useInitialBounds.setSelected(true);
    useInitialBounds.addActionListener(this);
    useReferenceSetBounds.addActionListener(this);
    useDynamicBounds.addActionListener(this);
    useZoomBounds.addActionListener(this);

    //initialize the seed list
    String[] seeds = new String[accumulators.size()];

    for (int i = 0; i < accumulators.size(); i++) {
        seeds[i] = localization.getString("text.seed", i + 1);
    }

    seedList = new JList(seeds);
    seedList.addListSelectionListener(this);

    selectAll = new JButton(new AbstractAction() {

        private static final long serialVersionUID = -3709557130361259485L;

        {
            putValue(Action.NAME, localization.getString("action.selectAll.name"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            seedList.getSelectionModel().setSelectionInterval(0, seedList.getModel().getSize() - 1);
        }

    });

    //initialize miscellaneous components
    paintHelper = new PaintHelper();
    paintHelper.set(localization.getString("text.referenceSet"), Color.BLACK);

    chartContainer = new JPanel(new BorderLayout());
}

From source file:nz.govt.natlib.ndha.manualdeposit.CMSSearchResults.java

@SuppressWarnings("serial")
private void formWindowOpened(java.awt.event.WindowEvent evt) { // NOPMD
    try {/* ww  w .ja  v  a  2  s  . c  o  m*/
        theFormControl = new FormControl(this, theSettingsPath);
    } catch (Exception ex) {
        LOG.error("Error loading form parameters", ex);
    }
    if (theFormControl != null) {
        final Action updateDividersAction = new AbstractAction() {
            public void actionPerformed(final ActionEvent e) {
                Timer t = (Timer) e.getSource();
                t.stop();
                splitMain.setDividerLocation(theFormControl.getExtra(SPLIT_NAME, 320));
                splitMain.repaint();
                for (int i = 0; i < tblResults.getColumnModel().getColumnCount(); i++) {
                    TableColumn col = tblResults.getColumnModel().getColumn(i);
                    String colName = "Col" + i;
                    int width = theFormControl.getExtra(colName, 150);
                    col.setPreferredWidth(width);
                    col.setWidth(width);
                }
            }
        };
        new Timer(200, updateDividersAction).start();
    }
    thePresenter.showResults();
}

From source file:org.nuclos.client.common.NuclosCollectController.java

/**
 * @todo this method is misused - it sets shortcuts for many things other than tabs...
 * @param frame/*from  w  w  w.  j a  v a 2  s.  c  om*/
 */
@Override
protected void setupShortcutsForTabs(MainFrameTab frame) {
    final CollectPanel<Clct> pnlCollect = this.getCollectPanel();
    final DetailsPanel pnlDetails = this.getDetailsPanel();

    final Action actSelectSearchTab = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            if (pnlCollect.isTabbedPaneEnabledAt(CollectPanel.TAB_SEARCH)) {
                pnlCollect.setTabbedPaneSelectedComponent(getSearchPanel());
            }
        }
    };
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.ACTIVATE_SEARCH_PANEL_1, actSelectSearchTab,
            pnlCollect);
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.ACTIVATE_SEARCH_PANEL_2, actSelectSearchTab,
            pnlCollect);

    //TODO This is a workaround. The detailpanel should keep the focus
    final Action actGrabFocus = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            pnlDetails.grabFocus();
        }
    };

    /**
     * A <code>ChainedAction</code> is an action composed of a primary and a secondary action.
     * It behaves exactly like the primary action, except that additionally, the secondary action is performed
     * after the primary action.
     */
    class ChainedAction implements Action {
        private final Action actPrimary;
        private final Action actSecondary;

        public ChainedAction(Action actPrimary, Action actSecondary) {
            this.actPrimary = actPrimary;
            this.actSecondary = actSecondary;
        }

        @Override
        public void addPropertyChangeListener(PropertyChangeListener listener) {
            actPrimary.addPropertyChangeListener(listener);
        }

        @Override
        public Object getValue(String sKey) {
            return actPrimary.getValue(sKey);
        }

        @Override
        public boolean isEnabled() {
            return actPrimary.isEnabled();
        }

        @Override
        public void putValue(String sKey, Object oValue) {
            actPrimary.putValue(sKey, oValue);
        }

        @Override
        public void removePropertyChangeListener(PropertyChangeListener listener) {
            actPrimary.removePropertyChangeListener(listener);
        }

        @Override
        public void setEnabled(boolean bEnabled) {
            actPrimary.setEnabled(bEnabled);
        }

        @Override
        public void actionPerformed(ActionEvent ev) {
            actPrimary.actionPerformed(ev);
            actSecondary.actionPerformed(ev);
        }
    }

    //final Action actRefresh = new ChainedAction(this.getRefreshCurrentCollectableAction(), actGrabFocus);

    this.getCollectPanel().setTabbedPaneToolTipTextAt(CollectPanel.TAB_SEARCH,
            getSpringLocaleDelegate().getMessage("NuclosCollectController.13", "Suche (F7) (Strg+F)"));
    this.getCollectPanel().setTabbedPaneToolTipTextAt(CollectPanel.TAB_RESULT,
            getSpringLocaleDelegate().getMessage("NuclosCollectController.7", "Ergebnis (F8)"));
    this.getCollectPanel().setTabbedPaneToolTipTextAt(CollectPanel.TAB_DETAILS,
            getSpringLocaleDelegate().getMessage("NuclosCollectController.3", "Details (F2)"));

    // the search action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.START_SEARCH, this.getSearchAction(),
            pnlCollect);
    KeyBinding keybinding = KeyBindingProvider.REFRESH;

    // the refresh action
    KeyBindingProvider.removeActionFromComponent(keybinding, pnlDetails);
    pnlDetails.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(keybinding.getKeystroke(),
            keybinding.getKey());
    pnlDetails.getActionMap().put(keybinding.getKey(), this.getRefreshCurrentCollectableAction());
    KeyBindingProvider.removeActionFromComponent(keybinding, getResultPanel());
    getResultPanel().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(keybinding.getKeystroke(),
            keybinding.getKey());
    getResultPanel().getActionMap().put(keybinding.getKey(), getResultPanel().btnRefresh.getAction());

    // the new action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.NEW, this.getNewAction(), pnlDetails);

    // the new with search values action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.NEW_SEARCHVALUE,
            this.getNewWithSearchValuesAction(), pnlCollect);

    // the save action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.SAVE_1, this.getSaveAction(), pnlCollect);
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.SAVE_2, this.getSaveAction(), pnlCollect);

    // first the navigation actions are performed and then the focus is grabbed:
    final Action actFirst = new ChainedAction(this.getFirstAction(), actGrabFocus);
    final Action actLast = new ChainedAction(this.getLastAction(), actGrabFocus);
    final Action actPrevious = new ChainedAction(this.getPreviousAction(), actGrabFocus);
    final Action actNext = new ChainedAction(this.getNextAction(), actGrabFocus);

    // the first action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.FIRST, actFirst, pnlDetails);
    pnlDetails.btnFirst.setAction(actFirst);

    // the last action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.LAST, actLast, pnlDetails);
    pnlDetails.btnLast.setAction(actLast);

    // the previous action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.PREVIOUS_1, actPrevious, pnlDetails);
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.PREVIOUS_2, actPrevious, pnlDetails);
    pnlDetails.btnPrevious.setAction(actPrevious);

    // the next action
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.NEXT_1, actNext, pnlDetails);
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.NEXT_2, actNext, pnlDetails);
    pnlDetails.btnNext.setAction(actNext);

    Action actClose = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getTab().dispose();
        }
    };
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.CLOSE_CHILD, actClose, pnlCollect);

    if (getResultPanel() != null && getResultTable() != null) {
        final JButton btnEdit = getResultPanel().btnEdit;
        KeyBindingProvider.bindActionToComponent(KeyBindingProvider.EDIT_1, btnEdit.getAction(),
                getResultTable());
        if (getResultTable().getActionMap().get(KeyBindingProvider.EDIT_2.getKey()) == null)
            KeyBindingProvider.bindActionToComponent(KeyBindingProvider.EDIT_2, btnEdit.getAction(),
                    getResultTable());
    }
}

From source file:org.kse.gui.dialogs.sign.DSignJar.java

private void initComponents(String signatureName) throws CryptoException {

    jlInputJar = new JLabel(res.getString("DSignJar.jlInputJar.text"));
    jtfInputJar = new JTextField(30);
    jtfInputJar.setCaretPosition(0);/*from   w w w. ja va2  s. c o m*/
    jtfInputJar.setToolTipText(res.getString("DSignJar.jtfInputJar.tooltip"));

    jbInputJarBrowse = new JButton(res.getString("DSignJar.jbInputJarBrowse.text"));
    PlatformUtil.setMnemonic(jbInputJarBrowse, res.getString("DSignJar.jbInputJarBrowse.mnemonic").charAt(0));
    jbInputJarBrowse.setToolTipText(res.getString("DSignJar.jbInputJarBrowse.tooltip"));

    jlSignDirectly = new JLabel(res.getString("DSignJar.jlSignDirectly.text"));
    jcbSignDirectly = new JCheckBox();
    jcbSignDirectly.setSelected(true);
    jcbSignDirectly.setToolTipText(res.getString("DSignJar.jcbSignDirectly.tooltip"));

    jlOutputJar = new JLabel(res.getString("DSignJar.jlOutputJar.text"));
    jtfOutputJar = new JTextField(30);
    jtfOutputJar.setEnabled(false);
    jtfOutputJar.setCaretPosition(0);
    jtfOutputJar.setToolTipText(res.getString("DSignJar.jtfOutputJar.tooltip"));

    jbOutputJarBrowse = new JButton(res.getString("DSignJar.jbOutputJarBrowse.text"));
    PlatformUtil.setMnemonic(jbOutputJarBrowse, res.getString("DSignJar.jbOutputJarBrowse.mnemonic").charAt(0));
    jbOutputJarBrowse.setToolTipText(res.getString("DSignJar.jbOutputJarBrowse.tooltip"));
    jbOutputJarBrowse.setEnabled(false);

    jlSignatureName = new JLabel(res.getString("DSignJar.jlSignatureName.text"));
    jtfSignatureName = new JTextField(convertSignatureName(signatureName), 15);
    jtfSignatureName.setCaretPosition(0);
    jtfSignatureName.setToolTipText(res.getString("DSignJar.jtfSignatureName.tooltip"));

    jlSignatureAlgorithm = new JLabel(res.getString("DSignJar.jlSignatureAlgorithm.text"));
    jcbSignatureAlgorithm = new JComboBox<SignatureType>();
    DialogHelper.populateSigAlgs(signKeyPairType, this.signPrivateKey, provider, jcbSignatureAlgorithm);
    jcbSignatureAlgorithm.setToolTipText(res.getString("DSignJar.jcbSignatureAlgorithm.tooltip"));

    jlDigestAlgorithm = new JLabel(res.getString("DSignJar.jlDigestAlgorithm.text"));
    jcbDigestAlgorithm = new JComboBox<DigestType>();
    populateDigestAlgs();
    jcbDigestAlgorithm.setToolTipText(res.getString("DSignJar.jcbDigestAlgorithm.tooltip"));

    jlAddTimestamp = new JLabel(res.getString("DSignJar.jlAddTimestamp.text"));
    jcbAddTimestamp = new JCheckBox();
    jcbAddTimestamp.setSelected(false);
    jcbAddTimestamp.setToolTipText(res.getString("DSignJar.jcbAddTimestamp.tooltip"));

    jlTimestampServerUrl = new JLabel(res.getString("DSignJar.jlTimestampServerUrl.text"));
    jcbTimestampServerUrl = new JComboBox<String>();
    jcbTimestampServerUrl.setEditable(true);
    jcbTimestampServerUrl.setEnabled(false);
    jcbTimestampServerUrl.setToolTipText(res.getString("DSignJar.jcbTimestampServerUrl.tooltip"));
    jcbTimestampServerUrl.setModel(new DefaultComboBoxModel<String>(getTsaUrls()));

    jbOK = new JButton(res.getString("DSignJar.jbOK.text"));

    jbCancel = new JButton(res.getString("DSignJar.jbCancel.text"));
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);

    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel);

    // layout
    Container pane = getContentPane();
    pane.setLayout(new MigLayout("insets dialog, fill", "[para]unrel[right]unrel[]", "[]unrel[]"));
    MiGUtil.addSeparator(pane, res.getString("DSignJar.jlFiles.text"));
    pane.add(jlInputJar, "skip");
    pane.add(jtfInputJar, "sgx");
    pane.add(jbInputJarBrowse, "wrap");
    pane.add(jlSignDirectly, "skip");
    pane.add(jcbSignDirectly, "wrap");
    pane.add(jlOutputJar, "skip");
    pane.add(jtfOutputJar, "sgx");
    pane.add(jbOutputJarBrowse, "wrap para");
    MiGUtil.addSeparator(pane, res.getString("DSignJar.jlSignature.text"));
    pane.add(jlSignatureName, "skip");
    pane.add(jtfSignatureName, "sgx, wrap");
    pane.add(jlSignatureAlgorithm, "skip");
    pane.add(jcbSignatureAlgorithm, "sgx, wrap");
    pane.add(jlDigestAlgorithm, "skip");
    pane.add(jcbDigestAlgorithm, "sgx, wrap para");
    MiGUtil.addSeparator(pane, res.getString("DSignJar.jlTimestamp.text"));
    pane.add(jlAddTimestamp, "skip");
    pane.add(jcbAddTimestamp, "wrap");
    pane.add(jlTimestampServerUrl, "skip");
    pane.add(jcbTimestampServerUrl, "sgx, wrap para");
    pane.add(new JSeparator(), "spanx, growx, wrap para");
    pane.add(jpButtons, "right, spanx");

    // actions
    jbInputJarBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignJar.this);
                inputJarBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignJar.this);
            }
        }
    });

    jcbSignDirectly.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            jtfOutputJar.setEnabled(!jcbSignDirectly.isSelected());
            jbOutputJarBrowse.setEnabled(!jcbSignDirectly.isSelected());
        }
    });

    jbOutputJarBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignJar.this);
                outputJarBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignJar.this);
            }
        }
    });

    jcbAddTimestamp.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            jcbTimestampServerUrl.setEnabled(jcbAddTimestamp.isSelected());
        }
    });

    jbOK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });

    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setResizable(false);

    getRootPane().setDefaultButton(jbOK);

    pack();
    setLocationRelativeTo(null);
}

From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java

private void setKeyboardAccelerators() {
    serverList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control F"),
            "search");
    serverList.getActionMap().put("search", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override/*  w w  w  .j a  v a2s . c o  m*/
        public void actionPerformed(final ActionEvent e) {
            showFilter();
        }
    });
}