Fixed applet bug when not signed.

This commit is contained in:
Chris Cromer
2016-07-27 19:53:29 -04:00
parent 1ce043c21d
commit a0ba43ba8a
18 changed files with 399 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
Manifest-Version: 1.0
Permissions: sandbox
Permissions: all-permissions
Codebase: *.cromer.cl 127.0.0.1
JavaFX-Version: 8.0
Class-Path: /cl/cromer/estructuras

View File

@@ -11,6 +11,7 @@ import javafx.scene.image.Image;
import javafx.stage.Stage;
import java.io.IOException;
import java.security.AccessControlException;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Level;
@@ -38,11 +39,22 @@ public class Main extends Application {
*/
@Override
public void start(Stage stage) {
Preferences preferences = Preferences.userRoot().node(this.getClass().getName());
String idoma = preferences.get("idioma", "en");
String idoma2 = preferences.get("idioma2", "EN");
String idioma;
String idioma2;
Preferences preferences;
try {
preferences = Preferences.userRoot().node(this.getClass().getName());
idioma = preferences.get("idioma", "en");
idioma2 = preferences.get("idioma2", "EN");
}
catch (AccessControlException exception) {
// This will throw if the applet is not signed.
preferences = null;
idioma = "en";
idioma2 = "EN";
}
Locale locale = new Locale(idoma, idoma2);
Locale locale = new Locale(idioma, idioma2);
ResourceBundle resourceBundle = ResourceBundle.getBundle("cl.cromer.estructuras.bundles.Idioma", locale);
try {
@@ -58,7 +70,7 @@ public class Main extends Application {
stage.close();
}
//stage.setMaximized(true);
stage.setMaximized(true);
stage.setMinHeight(640);
stage.setMinWidth(768);
stage.getIcons().add(new Image(getClass().getResourceAsStream("/cl/cromer/estructuras/images/icon.png")));

View File

@@ -303,8 +303,10 @@ public class MenuController extends VBox implements Initializable {
Optional<ButtonType> result = dialog.showAndWait();
if (result.isPresent() && result.get() == botonCambiar) {
// Si hace click en cambiar, cambiar el idioma y reiniciar.
preferences.put("idioma", "en");
preferences.put("idioma2", "EN");
if (preferences != null) {
preferences.put("idioma", "en");
preferences.put("idioma2", "EN");
}
Locale locale = new Locale("en", "EN");
ResourceBundle resourceBundle = ResourceBundle.getBundle("cl.cromer.estructuras.bundles.Idioma", locale);
@@ -335,8 +337,10 @@ public class MenuController extends VBox implements Initializable {
Optional<ButtonType> result = dialog.showAndWait();
if (result.isPresent() && result.get() == botonCambiar) {
// Si hace click en cambiar, cambiar el idioma y reiniciar.
preferences.put("idioma", "es");
preferences.put("idioma2", "ES");
if (preferences != null) {
preferences.put("idioma", "es");
preferences.put("idioma2", "ES");
}
Locale locale = new Locale("es", "ES");
ResourceBundle resourceBundle = ResourceBundle.getBundle("cl.cromer.estructuras.bundles.Idioma", locale);