コード例 #1
0
ファイル: Text.java プロジェクト: lachlaan/Custom-Salem
 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));
       }
     }
   });
 }
コード例 #2
0
ファイル: Baseline.java プロジェクト: benbac20/jrdesktop
 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;
 }