Beispiel #1
0
 public static UText forfield(Furnace fnd, final Object obj, String fn) {
   final java.lang.reflect.Field f;
   try {
     f = obj.getClass().getField(fn);
   } catch (NoSuchFieldException e) {
     throw (new RuntimeException(e));
   }
   if (f.getType() != String.class) throw (new RuntimeException("Not a string field: " + f));
   return (new UText(fnd) {
     public String text() {
       try {
         return ((String) f.get(obj));
       } catch (IllegalAccessException e) {
         throw (new RuntimeException(e));
       }
     }
   });
 }
Beispiel #2
0
 private static boolean isOceanTheme() {
   if (!inSandbox) {
     try {
       java.lang.reflect.Field field = MetalLookAndFeel.class.getDeclaredField("currentTheme");
       field.setAccessible(true);
       Object theme = field.get(null);
       return "javax.swing.plaf.metal.OceanTheme".equals(theme.getClass().getName());
     } catch (Exception ex) {
       // We're in a sandbox and can't access the field
       inSandbox = true;
     }
   }
   if (!checkedForOcean) {
     checkedForOcean = true;
     checkForOcean();
   }
   return usingOcean;
 }