Search in sources :

Example 1 with ActionEvent

use of java.awt.event.ActionEvent in project checkstyle by checkstyle.

the class OperatorHelper method myMethod.

//indent:4 exp:4
private void myMethod() {
    //indent:4 exp:4
    class localFoo {
    }
    class localFoo2 {

        //indent:12 exp:12
        int x;

        //indent:12 exp:12
        int func() {
            return 3;
        }
    }
    //indent:8 exp:8
    //     : this is broken right now: //indent:8 exp:8
    //   1) this is both an expression and an OBJBLOCK //indent:8 exp:8
    //   2) methods aren't yet parsed //indent:8 exp:8
    //   3) only CLASSDEF is handled now, not OBJBLOCK //indent:8 exp:8
    new JButton().addActionListener(new //indent:8 exp:8
    ActionListener() {

        //indent:8 exp:8
        public void actionPerformed(ActionEvent e) {
        //indent:12 exp:12
        }
    });
    //indent:8 exp:8
    new JButton().addActionListener(new //indent:8 exp:8
    ActionListener() {

        public void actionPerformed(ActionEvent e) {
            //indent:12 exp:12
            //indent:16 exp:16
            int i = 2;
        }
    });
    //indent:8 exp:8
    Object o = new //indent:8 exp:8
    ActionListener() {

        //indent:8 exp:8
        public void actionPerformed(ActionEvent e) {
        //indent:12 exp:12
        }
    };
    //indent:8 exp:8
    myfunc2(//indent:8 exp:8
    10, //indent:8 exp:8
    10, //indent:8 exp:8
    10, myfunc3(//indent:12 exp:>=12
    11, //indent:12 exp:>=12
    11, 11, //indent:16 exp:>=16
    11), //indent:12 exp:>=12
    10, //indent:12 exp:>=12
    10, //indent:12 exp:>=12
    10);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton)

Example 2 with ActionEvent

use of java.awt.event.ActionEvent in project checkstyle by checkstyle.

the class MyAnnotation3 method holder.

/** methods in anonymous inner classes */
void holder() {
    Action a = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
        }

        void somethingElse(@MyAnnotation3 ActionEvent e) {
        }
    };
    Action b = new AbstractAction() {

        public void actionPerformed(final ActionEvent e) {
        }

        void somethingElse(@MyAnnotation3 final ActionEvent e) {
        }
    };
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 3 with ActionEvent

use of java.awt.event.ActionEvent in project enumerable by hraberg.

the class LambdaTest method createSingleMethodInterfaceTakingOneArgumentUsingGenericDelegate.

@Test
public void createSingleMethodInterfaceTakingOneArgumentUsingGenericDelegate() throws Exception {
    ActionEvent actual;
    ActionListener a = delegate(e, actual = e);
    ActionEvent event = new ActionEvent(this, 1, "command");
    a.actionPerformed(event);
    assertSame(event, actual);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Test(org.junit.Test)

Example 4 with ActionEvent

use of java.awt.event.ActionEvent in project languagetool by languagetool-org.

the class LanguageManagerDialog method show.

public void show() {
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiLanguageManagerDialog"));
    // close dialog when user presses Escape key:
    // TODO: taken from ConfigurationDialog, avoid duplication:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {

        @Override
        @SuppressWarnings("unused")
        public void actionPerformed(ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    list = new JList<>(ruleFiles.toArray(new File[ruleFiles.size()]));
    GridBagConstraints cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    contentPane.add(new JScrollPane(list), cons);
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.fill = GridBagConstraints.HORIZONTAL;
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    addButton = new JButton(messages.getString("guiAddButton"));
    addButton.addActionListener(this);
    cons.gridx = 1;
    cons.gridy = 0;
    buttonPanel.add(addButton, cons);
    removeButton = new JButton(messages.getString("guiRemoveButton"));
    removeButton.addActionListener(this);
    cons.gridx = 1;
    cons.gridy = 1;
    buttonPanel.add(removeButton, cons);
    closeButton = new JButton(messages.getString("guiCloseButton"));
    closeButton.addActionListener(this);
    cons.gridx = 1;
    cons.gridy = 2;
    buttonPanel.add(closeButton, cons);
    cons.gridx = 1;
    cons.gridy = 0;
    cons = new GridBagConstraints();
    cons.anchor = GridBagConstraints.NORTH;
    contentPane.add(buttonPanel, cons);
    dialog.pack();
    dialog.setSize(300, 200);
    dialog.setLocationByPlatform(true);
    dialog.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Container(java.awt.Container) ActionListener(java.awt.event.ActionListener) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Example 5 with ActionEvent

use of java.awt.event.ActionEvent in project jna by java-native-access.

the class ShapedWindowDemo method main.

public static void main(String[] args) {
    try {
        System.setProperty("sun.java2d.noddraw", "true");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
    final JFrame frame = new JFrame("Shaped Window Demo");
    MouseInputAdapter handler = new MouseInputAdapter() {

        private Point offset;

        private void showPopup(MouseEvent e) {
            final JPopupMenu m = new JPopupMenu();
            m.add(new AbstractAction("Hide") {

                public void actionPerformed(ActionEvent e) {
                    frame.setState(JFrame.ICONIFIED);
                }

                private static final long serialVersionUID = 1L;
            });
            m.add(new AbstractAction("Close") {

                public void actionPerformed(ActionEvent e) {
                    System.exit(0);
                }

                private static final long serialVersionUID = 1L;
            });
            m.pack();
            m.show(e.getComponent(), e.getX(), e.getY());
        }

        public void mousePressed(MouseEvent e) {
            offset = e.getPoint();
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        public void mouseDragged(MouseEvent e) {
            if (!SwingUtilities.isLeftMouseButton(e))
                return;
            Point where = e.getPoint();
            where.translate(-offset.x, -offset.y);
            Point loc = frame.getLocationOnScreen();
            loc.translate(where.x, where.y);
            frame.setLocation(loc.x, loc.y);
        }

        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }
    };
    frame.addMouseListener(handler);
    frame.addMouseMotionListener(handler);
    ClockFace face = new ClockFace(new Dimension(150, 150));
    frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    frame.getContentPane().add(face);
    frame.setUndecorated(true);
    try {
        Shape mask = new Area(new Ellipse2D.Float(0, 0, 150, 150));
        WindowUtils.setWindowMask(frame, mask);
        if (WindowUtils.isWindowAlphaSupported()) {
            WindowUtils.setWindowAlpha(frame, .7f);
        }
        frame.setIconImage(face.getIconImage());
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocation(100, 100);
        frame.setVisible(true);
    } catch (UnsatisfiedLinkError e) {
        e.printStackTrace();
        String msg = e.getMessage() + "\nError loading the JNA library";
        JTextArea area = new JTextArea(msg);
        area.setOpaque(false);
        area.setFont(UIManager.getFont("Label.font"));
        area.setEditable(false);
        area.setColumns(80);
        area.setRows(8);
        area.setWrapStyleWord(true);
        area.setLineWrap(true);
        JOptionPane.showMessageDialog(frame, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) Shape(java.awt.Shape) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) Point(java.awt.Point) Dimension(java.awt.Dimension) JPopupMenu(javax.swing.JPopupMenu) Ellipse2D(java.awt.geom.Ellipse2D) Area(java.awt.geom.Area) JTextArea(javax.swing.JTextArea) JFrame(javax.swing.JFrame) AbstractAction(javax.swing.AbstractAction) MouseInputAdapter(javax.swing.event.MouseInputAdapter)

Aggregations

ActionEvent (java.awt.event.ActionEvent)3561 ActionListener (java.awt.event.ActionListener)2755 JButton (javax.swing.JButton)1116 JPanel (javax.swing.JPanel)961 JLabel (javax.swing.JLabel)606 JMenuItem (javax.swing.JMenuItem)550 Dimension (java.awt.Dimension)531 AbstractAction (javax.swing.AbstractAction)510 BorderLayout (java.awt.BorderLayout)381 GridBagConstraints (java.awt.GridBagConstraints)301 GridBagLayout (java.awt.GridBagLayout)292 Insets (java.awt.Insets)288 JScrollPane (javax.swing.JScrollPane)274 BoxLayout (javax.swing.BoxLayout)262 JTextField (javax.swing.JTextField)262 FlowLayout (java.awt.FlowLayout)257 JCheckBox (javax.swing.JCheckBox)242 JMenu (javax.swing.JMenu)217 Point (java.awt.Point)203 ImageIcon (javax.swing.ImageIcon)191