Search in sources :

Example 71 with KeyEvent

use of java.awt.event.KeyEvent in project android by JetBrains.

the class DragFixture method pressKey.

public DragFixture pressKey(@MagicConstant(flagsFromClass = KeyEvent.class) int keyCode, char keyChar) {
    if (keyCode == KeyEvent.VK_SHIFT) {
        myModifiers |= InputEvent.SHIFT_MASK;
    }
    if (keyCode == KeyEvent.VK_META) {
        myModifiers |= InputEvent.META_MASK;
    }
    if (keyCode == KeyEvent.VK_CONTROL) {
        myModifiers |= InputEvent.CTRL_MASK;
    }
    if (keyCode == KeyEvent.VK_ALT) {
        myModifiers |= InputEvent.ALT_MASK;
    }
    DesignSurface surface = myScreen.getSurface();
    KeyEvent event = new KeyEventBuilder(keyCode, keyChar).withSource(surface).build();
    myInteraction.keyPressed(event);
    return this;
}
Also used : KeyEvent(java.awt.event.KeyEvent) DesignSurface(com.android.tools.idea.uibuilder.surface.DesignSurface)

Example 72 with KeyEvent

use of java.awt.event.KeyEvent in project android by JetBrains.

the class DragFixture method releaseKey.

public DragFixture releaseKey(@MagicConstant(flagsFromClass = KeyEvent.class) int keyCode, char keyChar) {
    if (keyCode == KeyEvent.VK_SHIFT) {
        myModifiers |= InputEvent.SHIFT_MASK;
    }
    if (keyCode == KeyEvent.VK_META) {
        myModifiers |= InputEvent.META_MASK;
    }
    if (keyCode == KeyEvent.VK_CONTROL) {
        myModifiers |= InputEvent.CTRL_MASK;
    }
    if (keyCode == KeyEvent.VK_ALT) {
        myModifiers |= InputEvent.ALT_MASK;
    }
    DesignSurface surface = myScreen.getSurface();
    KeyEvent event = new KeyEventBuilder(keyCode, keyChar).withSource(surface).build();
    myInteraction.keyReleased(event);
    return this;
}
Also used : KeyEvent(java.awt.event.KeyEvent) DesignSurface(com.android.tools.idea.uibuilder.surface.DesignSurface)

Example 73 with KeyEvent

use of java.awt.event.KeyEvent in project jdk8u_jdk by JetBrains.

the class Test8013370 method run.

@Override
public void run() {
    if (this.frame == null) {
        JMenuBar menu = new JMenuBar() {

            @Override
            protected boolean processKeyBinding(KeyStroke stroke, KeyEvent event, int condition, boolean pressed) {
                if (stroke == null) {
                    Test8013370.this.error = true;
                    return false;
                }
                return super.processKeyBinding(stroke, event, condition, pressed);
            }
        };
        menu.add(new JMenuItem("Menu"));
        InputMap map = menu.getInputMap(WHEN_IN_FOCUSED_WINDOW);
        // from a array to a hashtable when more than 8 values are added.
        for (int i = 0; i < 9; i++) {
            String name = " Action #" + i;
            map.put(KeyStroke.getKeyStroke(KeyEvent.VK_A + i, CTRL_DOWN_MASK), name);
            menu.getActionMap().put(name, new AbstractAction(name) {

                @Override
                public void actionPerformed(ActionEvent event) {
                    showMessageDialog(null, getValue(NAME));
                }
            });
        }
        this.frame = new JFrame("8013370");
        this.frame.setJMenuBar(menu);
        this.frame.setVisible(true);
    } else {
        this.frame.dispose();
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) JFrame(javax.swing.JFrame) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) InputMap(javax.swing.InputMap) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JMenuBar(javax.swing.JMenuBar)

Example 74 with KeyEvent

use of java.awt.event.KeyEvent in project bytecode-viewer by Konloch.

the class PaneUpdaterThread method run.

public void run() {
    try {
        final byte[] b = BytecodeViewer.getClassBytes(viewer.container, viewer.cn.name + ".class");
        if (decompiler != Decompiler.HEXCODE) {
            RSyntaxTextArea panelArea = new RSyntaxTextArea();
            panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
            panelArea.setCodeFoldingEnabled(true);
            panelArea.setAntiAliasingEnabled(true);
            final RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
            panelArea.setText(decompiler.decompileClassNode(viewer.cn, b));
            panelArea.setCaretPosition(0);
            panelArea.setEditable(viewer.isPaneEditable(paneId));
            panelArea.addKeyListener(new KeyListener() {

                @Override
                public void keyPressed(KeyEvent e) {
                    if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
                        viewer.requestFocus(paneId);
                    }
                    BytecodeViewer.checkHotKey(e);
                }

                @Override
                public void keyReleased(KeyEvent arg0) {
                }

                @Override
                public void keyTyped(KeyEvent arg0) {
                }
            });
            scrollPane.setColumnHeaderView(new JLabel(decompiler.getName() + " Decompiler - Editable: " + panelArea.isEditable()));
            panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    target.add(scrollPane);
                }
            });
            viewer.updatePane(paneId, panelArea, decompiler);
        } else {
            final JHexEditor hex = new JHexEditor(b);
            hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    target.add(hex);
                }
            });
        }
    } catch (Exception e) {
        new ExceptionUI(e);
    } finally {
        viewer.resetDivider();
        BytecodeViewer.viewer.setIcon(false);
        if (button != null)
            button.setEnabled(true);
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) JHexEditor(com.jhe.hexed.JHexEditor) RSyntaxTextArea(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea) ExceptionUI(the.bytecode.club.bytecodeviewer.api.ExceptionUI) KeyListener(java.awt.event.KeyListener) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane)

Example 75 with KeyEvent

use of java.awt.event.KeyEvent in project dogecade by ebanisadr.

the class MainMenu method createUIComponents.

private void createUIComponents() {
    myAccountButton = new JButton("My MyProfileScreen");
    myAccountButton.addActionListener(e -> MyAccountScreen.showMyAccountWindow());
    chatTextArea = new JChatBox();
    sendButton = new JButton("send");
    sendButton.addActionListener(e -> ((JChatBox) chatTextArea).getMessageFromEnterBox());
    enterTextField = new JTextField();
    enterTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                ((JChatBox) chatTextArea).getMessageFromEnterBox();
            }
        }
    });
    roomsPanel = new JPanel();
    JButton startRPSButton = new JButton("play rps against the computer");
    startRPSButton.addActionListener(e -> {
        List<Player> p = new ArrayList<>();
        p.add(new Player(Dogecade.server.getUsername(), BigDecimal.valueOf(100)));
        p.add(new Player("name2", BigDecimal.valueOf(33)));
        new RockPaperScissors(p, Dogecade.rpsServer, 3).startGame();
    });
    roomsPanel.add(startRPSButton);
}
Also used : KeyEvent(java.awt.event.KeyEvent) Player(dogecade.games.Player) RockPaperScissors(dogecade.games.rps.RockPaperScissors) ArrayList(java.util.ArrayList) KeyListener(java.awt.event.KeyListener)

Aggregations

KeyEvent (java.awt.event.KeyEvent)301 KeyAdapter (java.awt.event.KeyAdapter)159 MouseEvent (java.awt.event.MouseEvent)79 ActionEvent (java.awt.event.ActionEvent)74 JPanel (javax.swing.JPanel)69 ActionListener (java.awt.event.ActionListener)61 MouseAdapter (java.awt.event.MouseAdapter)59 KeyListener (java.awt.event.KeyListener)54 Dimension (java.awt.Dimension)50 JLabel (javax.swing.JLabel)48 JTextField (javax.swing.JTextField)44 BorderLayout (java.awt.BorderLayout)40 JButton (javax.swing.JButton)40 JScrollPane (javax.swing.JScrollPane)35 Insets (java.awt.Insets)33 Point (java.awt.Point)33 FocusEvent (java.awt.event.FocusEvent)31 GridBagConstraints (java.awt.GridBagConstraints)23 BoxLayout (javax.swing.BoxLayout)22 GridBagLayout (java.awt.GridBagLayout)20