summaryrefslogtreecommitdiff
path: root/java/awt/KeyboardFocusManager.java
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2005-07-07 12:37:03 +0000
committerRoman Kennke <roman@kennke.org>2005-07-07 12:37:03 +0000
commit8822004a89d6ccbf129f773cc2cfb8bef1eb4139 (patch)
tree237f77846bb742b340bd14fa89bfa43ceaadd258 /java/awt/KeyboardFocusManager.java
parent891925a4b8e438f6761e0928c558f2c7e2ea3b8c (diff)
downloadclasspath-8822004a89d6ccbf129f773cc2cfb8bef1eb4139.tar.gz
2005-07-07 Roman Kennke <roman@kennke.org>
* gnu/java/awt/FocusManager.java: New class. Provides a concrete implementation of javax.swing.FocusManager so that we can support the old-style FocusManager in Swing and AWT. * gnu/classpath/SystemProperties.java: Add new system property gnu.java.awt.FocusManager that sets the class that should be used as the default FocusManager in AWT and Swing. * java/awt/KeyboardFocusManager.java (setCurrentKeyboardFocusManager): Use createFocusManager instead of creating the instance directly. (createFocusManager): New method. Instantiate a KeyboardFocusManager that is set by the system property gnu.java.awt.FocusManager. * javax/swing.FocusManager.java (constructor): Call super() here. (getCurrentManager): Return the current AWT KeyboardFocusManager here. (setCurrentManager): Set the current AWT KeyboardFocusManager here. (processKeyEvent): Removed method. This is no longer in the API. (focusNextComponent): Removed method. This is no longer in the API. (focusPreviousComponent): Removed method. This is no longer in the API.
Diffstat (limited to 'java/awt/KeyboardFocusManager.java')
-rw-r--r--java/awt/KeyboardFocusManager.java42
1 files changed, 41 insertions, 1 deletions
diff --git a/java/awt/KeyboardFocusManager.java b/java/awt/KeyboardFocusManager.java
index b3b317046..f64618477 100644
--- a/java/awt/KeyboardFocusManager.java
+++ b/java/awt/KeyboardFocusManager.java
@@ -287,7 +287,7 @@ public abstract class KeyboardFocusManager
KeyboardFocusManager manager;
if (m == null)
- manager = new DefaultKeyboardFocusManager ();
+ manager = createFocusManager();
else
manager = m;
@@ -295,6 +295,46 @@ public abstract class KeyboardFocusManager
}
/**
+ * 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;
+ }
+ }
+
+ /**
* Retrieve the {@link Component} that has the keyboard focus, or
* null if the focus owner was not set by a thread in the current
* {@link java.lang.ThreadGroup}.