Preferences prefs = Preferences.userRoot().node("/com/lightcrafts/app");
prefs.putBoolean(StartupKey, true);
}
static void checkLastStartupSuccessful() {
Preferences prefs = Preferences.userRoot().node("/com/lightcrafts/app");
boolean wasSuccessful = prefs.getBoolean(StartupKey, true);
if (! wasSuccessful) {
JButton help = new JButton(LOCALE.get("StartupErrorHelpOption"));
help.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event) {
showHelpDialog();
}
}
);
JTextArea text = createText(LOCALE.get("StartupErrorMessage"));
int option = JOptionPane.showOptionDialog(
null,
text,
LOCALE.get("StartupErrorDialogTitle"),
JOptionPane.OK_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
new Object[] {
help,
LOCALE.get("StartupErrorResetOption"),
LOCALE.get("StartupErrorDontResetOption")
},
LOCALE.get("StartupErrorDontResetOption")
);
if (option == 1) {
text = createText(LOCALE.get("ResetWarningMajor"));
option = JOptionPane.showOptionDialog(
null,
text,
LOCALE.get("ResetDialogTitle"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
new Object[] {
help,
LOCALE.get("StartupErrorResetOption"),
LOCALE.get("StartupErrorDontResetOption")
},
LOCALE.get("StartupErrorDontResetOption")
);
if (option == 1) {
boolean success = true;
try {
Preferences root = Preferences.userRoot();
Preferences node = root.node("/com/lightcrafts");
node.removeNode();
}
catch (BackingStoreException e) {
System.err.println(
"StartupCrash failed to reset Preferences"
);