类java.awt.KeyEventPostProcessor源码实例Demo

下面列出了怎么用java.awt.KeyEventPostProcessor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk1.8-source-analysis   文件: UIManager.java
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);
}
 
源代码2 项目: dragonwell8_jdk   文件: UIManager.java
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);
}
 
源代码3 项目: TencentKona-8   文件: UIManager.java
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);
}
 
源代码4 项目: jdk8u60   文件: UIManager.java
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);
}
 
源代码5 项目: JDKSourceCode1.8   文件: UIManager.java
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);
}
 
源代码6 项目: openjdk-jdk8u   文件: UIManager.java
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);
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: UIManager.java
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);
}
 
源代码8 项目: Bytecoder   文件: UIManager.java
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);
}
 
源代码9 项目: openjdk-jdk9   文件: UIManager.java
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);
}
 
源代码10 项目: jdk8u-jdk   文件: UIManager.java
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);
}
 
源代码11 项目: Java8CN   文件: UIManager.java
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);
}
 
源代码12 项目: hottub   文件: UIManager.java
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);
}
 
源代码13 项目: openjdk-8-source   文件: UIManager.java
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);
}
 
源代码14 项目: openjdk-8   文件: UIManager.java
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);
}
 
源代码15 项目: jdk8u_jdk   文件: UIManager.java
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);
}
 
源代码16 项目: jdk8u-jdk   文件: UIManager.java
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);
}
 
源代码17 项目: jdk8u-dev-jdk   文件: UIManager.java
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);
}
 
源代码18 项目: PolyGlot   文件: ScrMainMenu.java
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());
}
 
 类所在包
 同包方法