Lazy initialization.

This commit is contained in:
Caspian Rychlik-Prince 2003-09-10 22:39:26 +00:00
parent 9148cb7c90
commit 14f38f43e5
1 changed files with 5 additions and 3 deletions

View File

@ -252,9 +252,8 @@ public class Keyboard {
/** The current state of the key being examined in the event queue */ /** The current state of the key being examined in the event queue */
public static boolean state; public static boolean state;
static { /** One time initialization */
initialize(); private static boolean initialized;
}
/** /**
* Keyboard cannot be constructed. * Keyboard cannot be constructed.
@ -268,6 +267,7 @@ public class Keyboard {
private static void initialize() { private static void initialize() {
System.loadLibrary(Sys.getLibraryName()); System.loadLibrary(Sys.getLibraryName());
initIDs(); initIDs();
initialized = true;
} }
/** /**
@ -282,6 +282,8 @@ public class Keyboard {
* @throws Exception if the keyboard could not be created for any reason * @throws Exception if the keyboard could not be created for any reason
*/ */
public static void create() throws Exception { public static void create() throws Exception {
if (!initialized)
initialize();
if (created) if (created)
return; return;
if (!nCreate()) if (!nCreate())