From 14f38f43e5742902b35d286f61b429305448f402 Mon Sep 17 00:00:00 2001 From: Caspian Rychlik-Prince Date: Wed, 10 Sep 2003 22:39:26 +0000 Subject: [PATCH] Lazy initialization. --- src/java/org/lwjgl/input/Keyboard.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/java/org/lwjgl/input/Keyboard.java b/src/java/org/lwjgl/input/Keyboard.java index ce0f229b..0c67e6c9 100644 --- a/src/java/org/lwjgl/input/Keyboard.java +++ b/src/java/org/lwjgl/input/Keyboard.java @@ -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())