java.awt.KeyEventPostProcessor Java Examples

The following examples show how to use java.awt.KeyEventPostProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UIManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #2
Source File: ScrMainMenu.java    From PolyGlot with MIT License 5 votes vote down vote up
private void setupEasterEgg() {
    class EnterKeyListener implements KeyEventPostProcessor {

        String lastChars = "------------------------------";

        @Override
        public boolean postProcessKeyEvent(KeyEvent e) {
            if (e != null && e.getKeyCode() == 0) {
                lastChars = lastChars.substring(1);
                lastChars += e.getKeyChar();

                if (lastChars.toLowerCase().endsWith("what did you see last tuesday")) {
                    InfoBox.info("Coded Response", "A pink elephant.", null);
                } else if (lastChars.toLowerCase().endsWith("this is the forest primeval")) {
                    InfoBox.info("Bearded with moss", "The murmuring pines and the hemlocks.", null);
                } else if (lastChars.toLowerCase().endsWith("it can't outlast you")) {
                    InfoBox.info("Just human...", "Yes it can. You're not a kukun.", null);
                } else if (lastChars.toLowerCase().endsWith("who's draque")
                        || lastChars.toLowerCase().endsWith("who is draque")) {
                    ScrEasterEgg.run(core.getRootWindow());
                } else if (lastChars.endsWith("uuddlrlrba")) {
                    InfoBox.info("コナミコマンド", "30の命を与えます。", null);
                }
            }

            return false;
        }
    }
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventPostProcessor(new EnterKeyListener());
}
 
Example #3
Source File: UIManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #4
Source File: UIManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #5
Source File: UIManager.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #6
Source File: UIManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #7
Source File: UIManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #8
Source File: UIManager.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #9
Source File: UIManager.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #10
Source File: UIManager.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #11
Source File: UIManager.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #12
Source File: UIManager.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #13
Source File: UIManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #14
Source File: UIManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #15
Source File: UIManager.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #16
Source File: UIManager.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #17
Source File: UIManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example #18
Source File: UIManager.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}