Search in sources :

Example 16 with AbstractAction

use of javax.swing.AbstractAction in project EnrichmentMapApp by BaderLab.

the class PostAnalysisPanelMediator method showDialog.

@SuppressWarnings("serial")
public void showDialog(Component parent, CyNetworkView netView) {
    final EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
    invokeOnEDT(() -> {
        final PostAnalysisInputPanel panel = panelFactory.create(map);
        final JDialog dialog = new JDialog(swingApplication.getJFrame(), "Add Signature Gene Sets", ModalityType.APPLICATION_MODAL);
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        JButton helpButton = SwingUtil.createOnlineHelpButton(EnrichmentMapBuildProperties.USER_MANUAL_URL, "Online Manual...", serviceRegistrar);
        JButton resetButton = new JButton("Reset");
        resetButton.addActionListener(e -> panel.reset());
        JButton closeButton = new JButton(new AbstractAction("Close") {

            @Override
            public void actionPerformed(ActionEvent e) {
                dialog.dispose();
            }
        });
        JButton runButton = new JButton(new AbstractAction("Add") {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (panel.isReady()) {
                    Optional<PostAnalysisParameters> params = buildPostAnalysisParameters(panel, map, dialog);
                    if (params.isPresent()) {
                        addGeneSets(netView, params.get());
                        dialog.dispose();
                    } else {
                        JOptionPane.showMessageDialog(panel, "Could not run post analysis.", "EnrichmentMap: Error", JOptionPane.WARNING_MESSAGE);
                    }
                }
            }
        });
        JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(runButton, closeButton, helpButton, resetButton);
        dialog.getContentPane().add(panel, BorderLayout.CENTER);
        dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
        LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), runButton.getAction(), closeButton.getAction());
        dialog.getRootPane().setDefaultButton(runButton);
        dialog.pack();
        dialog.setLocationRelativeTo(swingApplication.getJFrame());
        dialog.setVisible(true);
    });
}
Also used : JPanel(javax.swing.JPanel) Optional(java.util.Optional) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog)

Example 17 with AbstractAction

use of javax.swing.AbstractAction in project EnrichmentMapApp by BaderLab.

the class CardDialog method createButtonPanel.

@SuppressWarnings("serial")
private JPanel createButtonPanel() {
    finishButton = new JButton(new AbstractAction(params.getFinishButtonText()) {

        public void actionPerformed(ActionEvent e) {
            currentPage.finish();
        }
    });
    JButton cancelButton = new JButton(new AbstractAction("Cancel") {

        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    });
    AbstractButton[] additional = params.getAdditionalButtons();
    if (additional != null) {
        for (AbstractButton button : additional) {
            button.addActionListener(e -> {
                currentPage.extraButtonClicked(e.getActionCommand());
            });
        }
    }
    JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(finishButton, cancelButton, additional);
    LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), finishButton.getAction(), cancelButton.getAction());
    dialog.getRootPane().setDefaultButton(finishButton);
    return buttonPanel;
}
Also used : JPanel(javax.swing.JPanel) AbstractButton(javax.swing.AbstractButton) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) AbstractAction(javax.swing.AbstractAction)

Example 18 with AbstractAction

use of javax.swing.AbstractAction in project zaproxy by zaproxy.

the class StandardFieldsDialog method initialize.

private void initialize(Dimension dim, String[] tabLabels) {
    this.setLayout(new GridBagLayout());
    this.setSize(dim);
    if (tabLabels == null) {
        this.initializeSinglePane(dim);
    } else {
        this.initializeTabbed(dim, tabLabels);
    }
    //  Handle escape key to close the dialog    
    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    AbstractAction escapeAction = new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (hasCancelSaveButtons()) {
                cancelPressed();
                return;
            }
            savePressed();
        }
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
}
Also used : GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Example 19 with AbstractAction

use of javax.swing.AbstractAction in project zaproxy by zaproxy.

the class AbstractDialog method initialize.

/**
	 * This method initializes this
	 */
private void initialize() {
    this.setVisible(false);
    this.setIconImages(DisplayUtils.getZapIconImages());
    this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(300, 200);
    }
    this.setTitle(Constant.PROGRAM_NAME);
    //  Handle escape key to close the dialog    
    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    AbstractAction escapeAction = new AbstractAction() {

        private static final long serialVersionUID = 3516424501887406165L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dispatchEvent(new WindowEvent(AbstractDialog.this, WindowEvent.WINDOW_CLOSING));
        }
    };
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    getRootPane().getActionMap().put("ESCAPE", escapeAction);
}
Also used : ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Example 20 with AbstractAction

use of javax.swing.AbstractAction in project jdk8u_jdk by JetBrains.

the class LinearGradientPrintingTest method createUI.

public static void createUI() {
    f = new JFrame("LinearGradient Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);
    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);
    f.pack();
    f.setVisible(true);
}
Also used : Container(java.awt.Container) JFrame(javax.swing.JFrame) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) PrinterException(java.awt.print.PrinterException) AbstractAction(javax.swing.AbstractAction) PrinterJob(java.awt.print.PrinterJob)

Aggregations

AbstractAction (javax.swing.AbstractAction)174 ActionEvent (java.awt.event.ActionEvent)162 Action (javax.swing.Action)42 InputMap (javax.swing.InputMap)34 JButton (javax.swing.JButton)33 JMenu (javax.swing.JMenu)30 JPanel (javax.swing.JPanel)30 ActionListener (java.awt.event.ActionListener)24 JMenuItem (javax.swing.JMenuItem)24 ActionMap (javax.swing.ActionMap)23 JScrollPane (javax.swing.JScrollPane)16 JPopupMenu (javax.swing.JPopupMenu)15 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)14 BorderLayout (java.awt.BorderLayout)14 BoxLayout (javax.swing.BoxLayout)12 JSeparator (javax.swing.JSeparator)12 JDialog (javax.swing.JDialog)11 WindowEvent (java.awt.event.WindowEvent)9 JMenuBar (javax.swing.JMenuBar)9 JTextField (javax.swing.JTextField)9