Search in sources :

Example 1 with KeyEventPostProcessor

use of java.awt.KeyEventPostProcessor in project jdk8u_jdk by JetBrains.

the class UIManager method initialize.

/*
     * Only called by maybeInitialize().
     */
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);
}
Also used : KeyEvent(java.awt.event.KeyEvent) KeyEventPostProcessor(java.awt.KeyEventPostProcessor) Properties(java.util.Properties) Component(java.awt.Component)

Aggregations

Component (java.awt.Component)1 KeyEventPostProcessor (java.awt.KeyEventPostProcessor)1 KeyEvent (java.awt.event.KeyEvent)1 Properties (java.util.Properties)1