39 |
package java.awt; |
package java.awt; |
40 |
|
|
41 |
import java.applet.Applet; |
import java.applet.Applet; |
42 |
|
import java.awt.FocusTraversalPolicy; |
43 |
import java.awt.event.FocusEvent; |
import java.awt.event.FocusEvent; |
44 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
45 |
import java.awt.event.WindowEvent; |
import java.awt.event.WindowEvent; |
214 |
currentFocusOwners */ |
currentFocusOwners */ |
215 |
private static Map currentFocusCycleRoots = new HashMap (); |
private static Map currentFocusCycleRoots = new HashMap (); |
216 |
|
|
217 |
/** The default {@link FocusTraveralPolicy} that focus-managing |
/** The default {@link FocusTraversalPolicy} that focus-managing |
218 |
{@link Container}s will use to define their initial focus |
{@link Container}s will use to define their initial focus |
219 |
traversal policy. */ |
traversal policy. */ |
220 |
private FocusTraversalPolicy defaultPolicy; |
private FocusTraversalPolicy defaultPolicy; |
288 |
KeyboardFocusManager manager; |
KeyboardFocusManager manager; |
289 |
|
|
290 |
if (m == null) |
if (m == null) |
291 |
manager = createFocusManager(); |
manager = new DefaultKeyboardFocusManager(); |
292 |
else |
else |
293 |
manager = m; |
manager = m; |
294 |
|
|
296 |
} |
} |
297 |
|
|
298 |
/** |
/** |
|
* Creates a KeyboardFocusManager. The exact class is determined by the |
|
|
* system property 'gnu.java.awt.FocusManager'. If this is not set, |
|
|
* we default to DefaultKeyboardFocusManager. |
|
|
*/ |
|
|
private static KeyboardFocusManager createFocusManager() |
|
|
{ |
|
|
String fmClassName = System.getProperty("gnu.java.awt.FocusManager", |
|
|
"java.awt.DefaultKeyboardFocusManager"); |
|
|
try |
|
|
{ |
|
|
Class fmClass = Class.forName(fmClassName); |
|
|
KeyboardFocusManager fm = (KeyboardFocusManager) fmClass.newInstance(); |
|
|
return fm; |
|
|
} |
|
|
catch (ClassNotFoundException ex) |
|
|
{ |
|
|
System.err.println("The class " + fmClassName + " cannot be found."); |
|
|
System.err.println("Check the setting of the system property"); |
|
|
System.err.println("gnu.java.awt.FocusManager"); |
|
|
return null; |
|
|
} |
|
|
catch (InstantiationException ex) |
|
|
{ |
|
|
System.err.println("The class " + fmClassName + " cannot be"); |
|
|
System.err.println("instantiated."); |
|
|
System.err.println("Check the setting of the system property"); |
|
|
System.err.println("gnu.java.awt.FocusManager"); |
|
|
return null; |
|
|
} |
|
|
catch (IllegalAccessException ex) |
|
|
{ |
|
|
System.err.println("The class " + fmClassName + " cannot be"); |
|
|
System.err.println("accessed."); |
|
|
System.err.println("Check the setting of the system property"); |
|
|
System.err.println("gnu.java.awt.FocusManager"); |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
299 |
* Retrieve the {@link Component} that has the keyboard focus, or |
* Retrieve the {@link Component} that has the keyboard focus, or |
300 |
* null if the focus owner was not set by a thread in the current |
* null if the focus owner was not set by a thread in the current |
301 |
* {@link java.lang.ThreadGroup}. |
* {@link java.lang.ThreadGroup}. |
1327 |
* |
* |
1328 |
* @return a global object set by the current ThreadGroup, or null |
* @return a global object set by the current ThreadGroup, or null |
1329 |
* |
* |
1330 |
* @see getFocusOwner |
* @see #getFocusOwner() |
1331 |
* @see getPermanentFocusOwner |
* @see #getPermanentFocusOwner() |
1332 |
* @see getFocusedWindow |
* @see #getFocusedWindow() |
1333 |
* @see getActiveWindow |
* @see #getActiveWindow() |
1334 |
* @see getCurrentFocusCycleRoot |
* @see #getCurrentFocusCycleRoot() |
1335 |
*/ |
*/ |
1336 |
private Object getObject (Map globalMap) |
private Object getObject (Map globalMap) |
1337 |
{ |
{ |
1351 |
* @throws SecurityException if this is not the keyboard focus |
* @throws SecurityException if this is not the keyboard focus |
1352 |
* manager associated with the current {@link java.lang.ThreadGroup} |
* manager associated with the current {@link java.lang.ThreadGroup} |
1353 |
* |
* |
1354 |
* @see getGlobalFocusOwner |
* @see #getGlobalFocusOwner() |
1355 |
* @see getGlobalPermanentFocusOwner |
* @see #getGlobalPermanentFocusOwner() |
1356 |
* @see getGlobalFocusedWindow |
* @see #getGlobalFocusedWindow() |
1357 |
* @see getGlobalActiveWindow |
* @see #getGlobalActiveWindow() |
1358 |
* @see getGlobalCurrentFocusCycleRoot |
* @see #getGlobalCurrentFocusCycleRoot() |
1359 |
*/ |
*/ |
1360 |
private Object getGlobalObject (Map globalMap) |
private Object getGlobalObject (Map globalMap) |
1361 |
{ |
{ |
1395 |
* @param newObject the object to set |
* @param newObject the object to set |
1396 |
* @param property the property that will change |
* @param property the property that will change |
1397 |
* |
* |
1398 |
* @see setGlobalFocusOwner |
* @see #setGlobalFocusOwner(Component) |
1399 |
* @see setGlobalPermanentFocusOwner |
* @see #setGlobalPermanentFocusOwner(Component) |
1400 |
* @see setGlobalFocusedWindow |
* @see #setGlobalFocusedWindow(Window) |
1401 |
* @see setGlobalActiveWindow |
* @see #setGlobalActiveWindow(Window) |
1402 |
* @see setGlobalCurrentFocusCycleRoot |
* @see #setGlobalCurrentFocusCycleRoot(Container) |
1403 |
*/ |
*/ |
1404 |
private void setGlobalObject (Map globalMap, |
private void setGlobalObject (Map globalMap, |
1405 |
Object newObject, |
Object newObject, |