[Schmitzm-commits] r2189 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 16 18:26:37 CET 2013


Author: mojays
Date: 2013-01-16 18:26:36 +0100 (Wed, 16 Jan 2013)
New Revision: 2189

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
Log:
SwingUtil: Avoid possible exceptions in IOUtil instantiation

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2013-01-10 23:17:32 UTC (rev 2188)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2013-01-16 17:26:36 UTC (rev 2189)
@@ -84,6 +84,7 @@
 import javax.swing.DefaultCellEditor;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
+import javax.swing.JApplet;
 import javax.swing.JCheckBox;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JComboBox;
@@ -144,7 +145,6 @@
 import de.schmitzm.swing.input.ManualInputOption;
 import de.schmitzm.swing.input.MultipleOptionPane;
 import de.schmitzm.swing.table.ComponentRenderer;
-import de.schmitzm.swing.table.HighlightCellRenderer;
 
 /**
  * Diese Klasse beinhaltet statische Hilfsfunktionen fuer das Arbeiten mit
@@ -164,7 +164,20 @@
      *  because {@link SwingUtil} is a very common class for SCHMITZM projects, which is
      *  referenced very often, especially during main frame initialization.  
      */
-    public static final Class STARTING_CLASS = IOUtil.getApplicationMainClass();
+    public static final Class STARTING_CLASS = getApplicationClassIgnoreException();
+    /**
+     * Returns {@code null} if {@link IOUtil#getApplicationMainClass()}
+     * causes an {@link Exception}. This may be e.g. if {@link SwingUtil} is 
+     * instantiated by a {@link JApplet}. In this case some methods or instantiations
+     * in {@link IOUtil} violate the {@link SecurityManager}.
+     */
+    private static final Class getApplicationClassIgnoreException() {
+      try {
+        return IOUtil.getApplicationMainClass();
+      } catch (Throwable err) {
+        return null;
+      }
+    }
   
   
 	private static final Logger LOGGER = Logger.getLogger(SwingUtil.class



More information about the Schmitzm-commits mailing list