Search in sources :

Example 11 with AbstractAction

use of javax.swing.AbstractAction in project binnavi by google.

the class CGraphHotkeys method registerSearchKeys.

/**
   * Registers the hot keys used for searching through graphs.
   * 
   * @param view View searched by the hotkey actions.
   * @param searchField Search field used for searching through the graph.
   * @param inputMap Input map where the hotkeys are registered.
   * @param actionMap Action map where the hotkey actions are stored.
   */
private static void registerSearchKeys(final Graph2DView view, final CGraphSearchField searchField, final InputMap inputMap, final ActionMap actionMap) {
    inputMap.put(HotKeys.GRAPH_SEARCHFIELD_FOCUS_KEY.getKeyStroke(), "FOCUS_SEARCHFIELD");
    view.getInputMap().put(HotKeys.GRAPH_SEARCH_NEXT_KEY.getKeyStroke(), "NEXT");
    inputMap.put(HotKeys.GRAPH_SEARCH_NEXT_ZOOM_KEY.getKeyStroke(), "NEXT_ZOOM");
    inputMap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_KEY.getKeyStroke(), "PREVIOUS");
    inputMap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_ZOOM_KEY.getKeyStroke(), "PREVIOUS_ZOOM");
    view.getActionMap().put("NEXT", new AbstractAction() {

        private static final long serialVersionUID = -7289167985570632361L;

        @Override
        public void actionPerformed(final ActionEvent event) {
            searchField.centerNextSearchHit(false, false);
        }
    });
    actionMap.put("NEXT_ZOOM", new AbstractAction() {

        private static final long serialVersionUID = -74113347341296669L;

        @Override
        public void actionPerformed(final ActionEvent event) {
            searchField.centerNextSearchHit(false, true);
        }
    });
    actionMap.put("PREVIOUS", new AbstractAction() {

        private static final long serialVersionUID = 5698412623106859554L;

        @Override
        public void actionPerformed(final ActionEvent event) {
            searchField.centerNextSearchHit(true, false);
        }
    });
    actionMap.put("PREVIOUS_ZOOM", new AbstractAction() {

        /**
       * Used for serialization.
       */
        private static final long serialVersionUID = -5246885767421937156L;

        @Override
        public void actionPerformed(final ActionEvent event) {
            searchField.centerNextSearchHit(true, true);
        }
    });
    actionMap.put("FOCUS_SEARCHFIELD", new AbstractAction() {

        /**
       * Used for serialization.
       */
        private static final long serialVersionUID = 7918948798657638098L;

        @Override
        public void actionPerformed(final ActionEvent event) {
            searchField.requestFocusInWindow();
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 12 with AbstractAction

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

the class ManageAddOnsDialog method initialize.

/**
	 * This method initializes this
	 * 
	 */
private void initialize() {
    this.setTitle(Constant.messages.getString("cfu.manage.title"));
    //this.setContentPane(getJTabbed());
    this.setContentPane(getTopPanel());
    this.pack();
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(700, 500);
    }
    state = State.IDLE;
    // 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(ManageAddOnsDialog.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 13 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 14 with AbstractAction

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

the class RadialGradientPrintingTest method createUI.

public static void createUI() {
    f = new JFrame("RadialGradient Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
    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)

Example 15 with AbstractAction

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

the class TexturePaintPrintingTest method printTexture.

private static void printTexture() {
    f = new JFrame("Texture Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
    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)155 ActionEvent (java.awt.event.ActionEvent)143 Action (javax.swing.Action)35 JButton (javax.swing.JButton)33 JPanel (javax.swing.JPanel)30 InputMap (javax.swing.InputMap)29 JMenu (javax.swing.JMenu)29 JMenuItem (javax.swing.JMenuItem)23 ActionListener (java.awt.event.ActionListener)21 ActionMap (javax.swing.ActionMap)20 JScrollPane (javax.swing.JScrollPane)16 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)14 BorderLayout (java.awt.BorderLayout)14 JPopupMenu (javax.swing.JPopupMenu)14 BoxLayout (javax.swing.BoxLayout)12 JSeparator (javax.swing.JSeparator)12 JDialog (javax.swing.JDialog)11 JMenuBar (javax.swing.JMenuBar)9 Dimension (java.awt.Dimension)8 WindowEvent (java.awt.event.WindowEvent)8