Until recently my application worked well with preferences settings stored in my Windows registry.
Code I use:
public class Main {
public static final Preferences oracleMonitorPreferences = Preferences.userRoot().node("Oracle 3D Monitor");
public static PreferencesGameSettings oracleMonitorSettings;
public static void main(final String[] args) {
// 1/ set preferences (framerate in windows registry)
setPreferences();
// 2/ initialize "game"
final StandardGame oracleMonitor = new StandardGame("Oracle 3D Monitor", StandardGame.GameType.GRAPHICAL, oracleMonitorSettings);
// initialize the background color
oracleMonitor.setBackgroundColor(DevelopmentState.BACKGROUND_COLOR);
oracleMonitor.start(); // Start the game thread
// Apply state
final OracleMonitorGameState state = new OracleMonitorGameState();
GameStateManager.getInstance().attachChild(state);
}
/**
* Set preferences regarding the display like the framerate, the widht, the height of the window...
* Under windows, preferences are stored in the registry under:
* HKEY_CURRENT_USERSoftwareJavaSoftPrefs
*/
private static void setPreferences() {
try {
oracleMonitorPreferences.put("GameFramerate", "63");
oracleMonitorPreferences.put("GameFullscreen", "true");
oracleMonitorPreferences.put("GameWidth", "640");
oracleMonitorPreferences.put("GameHeight", "480");
oracleMonitorPreferences.put("GameDepthBits", "24");
oracleMonitorPreferences.sync();
}
catch (BackingStoreException bse) {
bse.printStackTrace();
}
oracleMonitorSettings = new PreferencesGameSettings(oracleMonitorPreferences);
}
}
It worked pretty well but now I get the following error:
18 juin 2008 22:46:32 com.jmex.game.DefaultUncaughtExceptionHandler uncaughtException
GRAVE: Main game loop broken by uncaught exception
java.lang.NullPointerException
at com.jme.system.PreferencesGameSettings.getDepthBits(PreferencesGameSettings.java:159)
at com.jmex.game.StandardGame.displayMins(StandardGame.java:311)
at com.jmex.game.StandardGame.initSystem(StandardGame.java:262)
at com.jmex.game.StandardGame.run(StandardGame.java:184)
at java.lang.Thread.run(Thread.java:619)
I presume, someting related to the changes made in version 3854 of file com.jme.system.PreferencesGameSettings. In fact the NullPointerException comes from Java 5 auto-boxing because com.jme.system.AbstractGameSettings#defaultDepthBits is not initialized (in brief is equal to null).
Maybe I'm misusing these classes, can someone help me?
TIA,
N.