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 */
public static boolean state;
static {
initialize();
}
/** One time initialization */
private static boolean initialized;
/**
* Keyboard cannot be constructed.
@ -268,6 +267,7 @@ public class Keyboard {
private static void initialize() {
System.loadLibrary(Sys.getLibraryName());
initIDs();
initialized = true;
}
/**
@ -282,6 +282,8 @@ public class Keyboard {
* @throws Exception if the keyboard could not be created for any reason
*/
public static void create() throws Exception {
if (!initialized)
initialize();
if (created)
return;
if (!nCreate())