Java 类java.awt.KeyEventPostProcessor 实例源码

项目:bigwarp    文件:BigWarp.java   
public void closeAll()
{
    final ArrayList< KeyEventPostProcessor > ks = new ArrayList< KeyEventPostProcessor >( keyEventPostProcessorSet );
    for ( final KeyEventPostProcessor ke : ks )
        removeKeyEventPostProcessor( ke );

    repeatedKeyEventsFixer.remove();

    viewerFrameP.setVisible( false );
    viewerFrameQ.setVisible( false );
    landmarkFrame.setVisible( false );

    viewerFrameP.getViewerPanel().stop();
    viewerFrameQ.getViewerPanel().stop();

    viewerFrameP.dispose();
    viewerFrameQ.dispose();
    landmarkFrame.dispose();
}
项目:OpenJSharp    文件: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);
}
项目: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);
}
项目:openjdk-jdk10    文件: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);
}
项目:openjdk9    文件: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);
}
项目: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);
}
项目:geoxygene    文件:Picking.java   
/**
 * Crée un comportement de picking
 * 
 * @param canvas
 *            le canvas dans lequel est créé le picking
 * @param scene
 *            le BranchGroup contenant les éléments à sélectionner
 */
public Picking(Canvas3D canvas, BranchGroup scene) {

    this.canvas3D = canvas;

    this.pickCanvas = new PickCanvas(this.canvas3D, scene);
    // Tolérance à partir de laquelle les objets en fonction de la distance
    // avec la souris
    // sera sélectionnée
    this.pickCanvas.setTolerance(5f);
    // Pour avoir des infos à partir des frontières de l'objet intersecté
    this.pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);

    // Le bouton controle est il enfoncé ?
    KeyboardFocusManager kbm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    kbm.addKeyEventPostProcessor(new KeyEventPostProcessor() {
        @Override
        public boolean postProcessKeyEvent(KeyEvent e) {
            if (e.getModifiers() == InputEvent.CTRL_MASK) {
                if (e.getID() == KeyEvent.KEY_PRESSED) {
                    Picking.PICKING_IS_CTRL_PRESSED = true;
                }
            }
            if (e.getID() == KeyEvent.KEY_RELEASED) {
                Picking.PICKING_IS_CTRL_PRESSED = false;
            }
            return false;
        }
    });

}
项目: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);
}
项目:lookaside_java-1.8.0-openjdk    文件: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);
}
项目:infobip-open-jdk-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);
}
项目: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);
}
项目:OLD-OpenJDK8    文件: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);
}
项目:openjdk-jdk7u-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);
}
项目:openjdk-icedtea7    文件: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);
}
项目:leader_election    文件:GenerateNodesDialog.java   
/**
 * The constructor for the GenerateNodesDialog class.
 *
 * @param p The parent Frame to add the Dialog to.
 */
public GenerateNodesDialog(GUI p){
    super(p, "Create new Nodes", true);
    GuiHelper.setWindowIcon(this);
    cancel.addActionListener(this);
    ok.addActionListener(this);

    Font f = distributionModelComboBox.getFont().deriveFont(Font.PLAIN);
    distributionModelComboBox.setFont(f);
    nodeTypeComboBox.setFont(f);
    connectivityModelComboBox.setFont(f);
    interferenceModelComboBox.setFont(f);
    mobilityModelComboBox.setFont(f);
    reliabilityModelComboBox.setFont(f);

    // Detect ESCAPE button
    KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addKeyEventPostProcessor(new KeyEventPostProcessor() {
        public boolean postProcessKeyEvent(KeyEvent e) {
            if(!e.isConsumed() && e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                GenerateNodesDialog.this.setVisible(false);
            }
            return false;
        }
    });

    this.setLocationRelativeTo(p);
    this.parent = p;
}
项目:bigwarp    文件:BigWarp.java   
public void addKeyEventPostProcessor( final KeyEventPostProcessor ke )
{
    keyEventPostProcessorSet.add( ke );
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor( ke );
}
项目:bigwarp    文件:BigWarp.java   
public void removeKeyEventPostProcessor( final KeyEventPostProcessor ke )
{
    keyEventPostProcessorSet.remove( ke );
    KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventPostProcessor( ke );
}
项目:jdk7-jdk    文件:UIManager.java   
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Enable the Swing default LayoutManager.
    String toolkitName = Toolkit.getDefaultToolkit().getClass().getName();
    // don't set default policy if this is XAWT.
    if (!"sun.awt.X11.XToolkit".equals(toolkitName)) {
        if (FocusManager.isFocusManagerEnabled()) {
            KeyboardFocusManager.getCurrentKeyboardFocusManager().
                setDefaultFocusTraversalPolicy(
                    new LayoutFocusTraversalPolicy());
        }
    }

    // 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);
}
项目:openjdk-source-code-learn    文件:UIManager.java   
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Enable the Swing default LayoutManager.
    String toolkitName = Toolkit.getDefaultToolkit().getClass().getName();
    // don't set default policy if this is XAWT.
    if (!"sun.awt.X11.XToolkit".equals(toolkitName)) {
        if (FocusManager.isFocusManagerEnabled()) {
            KeyboardFocusManager.getCurrentKeyboardFocusManager().
                setDefaultFocusTraversalPolicy(
                    new LayoutFocusTraversalPolicy());
        }
    }

    // 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);
}
项目:leader_election    文件:GlobalSettingsDialog.java   
/**
 * The constructor for the GlobalSettingsDialog class.
 *
 * @param parent The parent Frame to attach the dialog to.
 */
public GlobalSettingsDialog(JFrame parent){
    super(parent, "Global Settings", true);
    GuiHelper.setWindowIcon(this);

    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(650, 500));

    JTextArea text = new JTextArea();
    text.setEditable(false);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Configuration.printConfiguration(new PrintStream(os));
    text.setText(os.toString());
    text.setCaretPosition(0); // ensure that the top of the text is shown 
    JScrollPane spane = new JScrollPane(text);
    this.add(spane);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());

    JPanel settingsPanel = new JPanel();
    settingsPanel.setLayout(new BorderLayout());

    testForUpdatesAtStartup.setSelected(AppConfig.getAppConfig().checkForSinalgoUpdate);
    testForUpdatesAtStartup.addActionListener(this);
    settingsPanel.add(BorderLayout.LINE_START, testForUpdatesAtStartup);

    versionTest.addActionListener(this);
    settingsPanel.add(BorderLayout.EAST, versionTest);

    buttonPanel.add(settingsPanel);

    close.addActionListener(this);
    JPanel closePanel = new JPanel();
    closePanel.add(close);
    buttonPanel.add(BorderLayout.SOUTH, closePanel);

    this.add(BorderLayout.SOUTH, buttonPanel);

    // Detect ESCAPE button
    KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addKeyEventPostProcessor(new KeyEventPostProcessor() {
        public boolean postProcessKeyEvent(KeyEvent e) {
            if(!e.isConsumed() && e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                GlobalSettingsDialog.this.setVisible(false);
            }
            return false;
        }
    });

    this.getRootPane().setDefaultButton(close);

    this.pack();
    this.setLocationRelativeTo(parent);
    this.setVisible(true);
}
项目:javify    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#addKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void addKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.addKeyEventPostProcessor(p);
}
项目:javify    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#removeKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void removeKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.removeKeyEventPostProcessor(p);
}
项目:jvm-stm    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#addKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void addKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.addKeyEventPostProcessor(p);
}
项目:jvm-stm    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#removeKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void removeKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.removeKeyEventPostProcessor(p);
}
项目:JamVM-PH    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#addKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void addKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.addKeyEventPostProcessor(p);
}
项目:JamVM-PH    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#removeKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void removeKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.removeKeyEventPostProcessor(p);
}
项目:classpath    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#addKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void addKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.addKeyEventPostProcessor(p);
}
项目:classpath    文件:FocusManager.java   
/**
 * Wraps
 * {@link KeyboardFocusManager#removeKeyEventPostProcessor(KeyEventPostProcessor)}.
 *
 * @param p the post processor
 */
public void removeKeyEventPostProcessor(KeyEventPostProcessor p)
{
  wrapped.removeKeyEventPostProcessor(p);
}