Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.beans.*;
import javax.swing.event.*;
import sun.awt.EmbeddedFrame;
/**
* The KeyboardManager class is used to help dispatch keyboard actions for the
* WHEN_IN_FOCUSED_WINDOW style actions. Actions with other conditions are handled
* directly in JComponent.
*
* Here's a description of the symantics of how keyboard dispatching should work
* atleast as I understand it.
*
* KeyEvents are dispatched to the focused component. The focus manager gets first
* crack at processing this event. If the focus manager doesn't want it, then
* the JComponent calls super.processKeyEvent() this allows listeners a chance
* to process the event.
*
* If none of the listeners "consumes" the event then the keybindings get a shot.
* This is where things start to get interesting. First, KeyStokes defined with the
* WHEN_FOCUSED condition get a chance. If none of these want the event, then the component
* walks though it's parents looked for actions of type WHEN_ANCESTOR_OF_FOCUSED_COMPONENT.
*
* If no one has taken it yet, then it winds up here. We then look for components registered
* for WHEN_IN_FOCUSED_WINDOW events and fire to them. Note that if none of those are found
* then we pass the event to the menubars and let them have a crack at it. They're handled differently.
*
* Lastly, we check if we're looking at an internal frame. If we are and no one wanted the event
* then we move up to the InternalFrame's creator and see if anyone wants the event (and so on and so on).
*
*
* @see InputMap
*/
class KeyboardManager {
static KeyboardManager currentManager = new KeyboardManager();
/**
* maps top-level containers to a sub-hashtable full of keystrokes
*/
Hashtable> containerMap = new Hashtable<>();
/**
* Maps component/keystroke pairs to a topLevel container
* This is mainly used for fast unregister operations
*/
Hashtable componentKeyStrokeMap = new Hashtable<>();
public static KeyboardManager getCurrentManager() {
return currentManager;
}
public static void setCurrentManager(KeyboardManager km) {
currentManager = km;
}
/**
* register keystrokes here which are for the WHEN_IN_FOCUSED_WINDOW
* case.
* Other types of keystrokes will be handled by walking the hierarchy
* That simplifies some potentially hairy stuff.
*/
public void registerKeyStroke(KeyStroke k, JComponent c) {
Container topContainer = getTopAncestor(c);
if (topContainer == null) {
return;
}
Hashtable