287 |
KeyboardFocusManager manager; |
KeyboardFocusManager manager; |
288 |
|
|
289 |
if (m == null) |
if (m == null) |
290 |
manager = new DefaultKeyboardFocusManager (); |
manager = createFocusManager(); |
291 |
else |
else |
292 |
manager = m; |
manager = m; |
293 |
|
|
295 |
} |
} |
296 |
|
|
297 |
/** |
/** |
298 |
|
* Creates a KeyboardFocusManager. The exact class is determined by the |
299 |
|
* system property 'gnu.java.awt.FocusManager'. If this is not set, |
300 |
|
* we default to DefaultKeyboardFocusManager. |
301 |
|
*/ |
302 |
|
private static KeyboardFocusManager createFocusManager() |
303 |
|
{ |
304 |
|
String fmClassName = System.getProperty("gnu.java.awt.FocusManager", |
305 |
|
"java.awt.DefaultKeyboardFocusManager"); |
306 |
|
try |
307 |
|
{ |
308 |
|
Class fmClass = Class.forName(fmClassName); |
309 |
|
KeyboardFocusManager fm = (KeyboardFocusManager) fmClass.newInstance(); |
310 |
|
return fm; |
311 |
|
} |
312 |
|
catch (ClassNotFoundException ex) |
313 |
|
{ |
314 |
|
System.err.println("The class " + fmClassName + " cannot be found."); |
315 |
|
System.err.println("Check the setting of the system property"); |
316 |
|
System.err.println("gnu.java.awt.FocusManager"); |
317 |
|
return null; |
318 |
|
} |
319 |
|
catch (InstantiationException ex) |
320 |
|
{ |
321 |
|
System.err.println("The class " + fmClassName + " cannot be"); |
322 |
|
System.err.println("instantiated."); |
323 |
|
System.err.println("Check the setting of the system property"); |
324 |
|
System.err.println("gnu.java.awt.FocusManager"); |
325 |
|
return null; |
326 |
|
} |
327 |
|
catch (IllegalAccessException ex) |
328 |
|
{ |
329 |
|
System.err.println("The class " + fmClassName + " cannot be"); |
330 |
|
System.err.println("accessed."); |
331 |
|
System.err.println("Check the setting of the system property"); |
332 |
|
System.err.println("gnu.java.awt.FocusManager"); |
333 |
|
return null; |
334 |
|
} |
335 |
|
} |
336 |
|
|
337 |
|
/** |
338 |
* Retrieve the {@link Component} that has the keyboard focus, or |
* Retrieve the {@link Component} that has the keyboard focus, or |
339 |
* 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 |
340 |
* {@link java.lang.ThreadGroup}. |
* {@link java.lang.ThreadGroup}. |