/** Updates the UIs of all the known Frames. */
 private static void updateAllUIs() {
   // Check if the current UI is WindowsLookAndfeel and flush the XP style map.
   // Note: Change the package test if this class is moved to a different package.
   Class uiClass = UIManager.getLookAndFeel().getClass();
   if (uiClass.getPackage().equals(DesktopProperty.class.getPackage())) {
     XPStyle.invalidateStyle();
   }
   Frame appFrames[] = Frame.getFrames();
   for (int j = 0; j < appFrames.length; j++) {
     updateWindowUI(appFrames[j]);
   }
 }
Exemplo n.º 2
0
 public void actionPerformed(ActionEvent ae) {
   String cname = nameF.getText().trim();
   int state = conditions[stateC.getSelectedIndex()];
   try {
     if (isSpecialCase(cname)) {
       handleSpecialCase(cname, state);
     } else {
       JComponent comp = (JComponent) Class.forName(cname).newInstance();
       ComponentUI cui = UIManager.getUI(comp);
       cui.installUI(comp);
       results.setText("Map entries for " + cname + ":\n\n");
       if (inputB.isSelected()) {
         loadInputMap(comp.getInputMap(state), "");
         results.append("\n");
       }
       if (actionB.isSelected()) {
         loadActionMap(comp.getActionMap(), "");
         results.append("\n");
       }
       if (bindingB.isSelected()) {
         loadBindingMap(comp, state);
       }
     }
   } catch (ClassCastException cce) {
     results.setText(cname + " is not a subclass of JComponent.");
   } catch (ClassNotFoundException cnfe) {
     results.setText(cname + " was not found.");
   } catch (InstantiationException ie) {
     results.setText(cname + " could not be instantiated.");
   } catch (Exception e) {
     results.setText("Exception found:\n" + e);
     e.printStackTrace();
   }
 }
Exemplo n.º 3
0
 private void configureValue(Object value, Class columnClass) {
   if (columnClass == Object.class || columnClass == null) {
     setHorizontalAlignment(JLabel.LEADING);
   } else if (columnClass == Float.class || columnClass == Double.class) {
     if (numberFormat == null) {
       numberFormat = NumberFormat.getInstance();
     }
     setHorizontalAlignment(JLabel.TRAILING);
     setText((value == null) ? "" : ((NumberFormat) numberFormat).format(value));
   } else if (columnClass == Number.class) {
     setHorizontalAlignment(JLabel.TRAILING);
     // Super will have set value.
   } else if (columnClass == Icon.class || columnClass == ImageIcon.class) {
     setHorizontalAlignment(JLabel.CENTER);
     setIcon((value instanceof Icon) ? (Icon) value : null);
     setText("");
   } else if (columnClass == Date.class) {
     if (dateFormat == null) {
       dateFormat = DateFormat.getDateInstance();
     }
     setHorizontalAlignment(JLabel.LEADING);
     setText((value == null) ? "" : ((Format) dateFormat).format(value));
   } else {
     configureValue(value, columnClass.getSuperclass());
   }
 }
Exemplo n.º 4
0
    public Object createValue(UIDefaults table) {
      try {
        Class c = Class.forName(className, true, Thread.currentThread().getContextClassLoader());

        if (methodName == null) {
          return c.newInstance();
        }
        Method m = c.getMethod(methodName, (Class[]) null);

        return m.invoke(c, (Object[]) null);
      } catch (ClassNotFoundException cnfe) {
      } catch (IllegalAccessException iae) {
      } catch (InvocationTargetException ite) {
      } catch (NoSuchMethodException nsme) {
      } catch (InstantiationException ie) {
      }
      return null;
    }
 /** Creates a new instance. */
 public QuaquaPantherFileChooserLAF() {
   String targetClassName = "apple.laf.AquaLookAndFeel";
   try {
     setTarget((LookAndFeel) Class.forName(targetClassName).newInstance());
   } catch (Exception e) {
     throw new InternalError(
         "Unable to instanciate target Look and Feel \""
             + targetClassName
             + "\". "
             + e.getMessage());
   }
 }
Exemplo n.º 6
0
 protected BasicLookAndFeel createBaseLookAndFeel() {
   try {
     if (SystemInfo.isMac) {
       final String name = UIManager.getSystemLookAndFeelClassName();
       return (BasicLookAndFeel) Class.forName(name).newInstance();
     } else {
       return new IdeaLaf();
     }
   } catch (Exception e) {
     log(e);
   }
   return null;
 }
Exemplo n.º 7
0
 private static void applySystemFonts(UIDefaults defaults) {
   try {
     String fqn = UIUtil.getSystemLookAndFeelClassName();
     Object systemLookAndFeel = Class.forName(fqn).newInstance();
     final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
     superMethod.setAccessible(true);
     final UIDefaults systemDefaults = (UIDefaults) superMethod.invoke(systemLookAndFeel);
     for (Map.Entry<Object, Object> entry : systemDefaults.entrySet()) {
       if (entry.getValue() instanceof Font) {
         defaults.put(entry.getKey(), entry.getValue());
       }
     }
   } catch (Exception e) {
     log(e);
   }
 }
Exemplo n.º 8
0
 private void handleSpecialCase(String cname, int condition) {
   Component comp = null;
   JComponent mapComp = null;
   try {
     if (cname.equals("javax.swing.JApplet")
         || cname.equals("javax.swing.JDialog")
         || cname.equals("javax.swing.JFrame")
         || cname.equals("javax.swing.JWindow")) {
       comp = (Component) Class.forName(cname).newInstance();
       mapComp = (JComponent) ((JApplet) comp).getLayeredPane();
       results.setText("Map entries for " + cname + " (delegated to JRootPane):\n\n");
     } else if (cname.equals("javax.swing.JInternalFrame")) {
       JDesktopPane jdp = new JDesktopPane();
       JInternalFrame jif = new JInternalFrame("Demo");
       jif.setVisible(true);
       jdp.add(jif);
       mapComp = jif;
     }
     if (inputB.isSelected()) {
       loadInputMap(mapComp.getInputMap(condition), "");
       results.append("\n");
     }
     if (actionB.isSelected()) {
       loadActionMap(mapComp.getActionMap(), "");
       results.append("\n");
     }
     if (bindingB.isSelected()) {
       loadBindingMap(mapComp, condition);
     }
   } catch (ClassCastException cce) {
     results.setText(cname + " is not a subclass of JComponent.");
   } catch (ClassNotFoundException cnfe) {
     results.setText(cname + " was not found.");
   } catch (InstantiationException ie) {
     results.setText(cname + " could not be instantiated.");
   } catch (Exception e) {
     results.setText("Exception found:\n" + e);
     e.printStackTrace();
   }
 }
Exemplo n.º 9
0
  protected Object parseValue(String key, @NotNull String value) {
    if ("null".equals(value)) {
      return null;
    }

    if (key.endsWith("Insets")) {
      return parseInsets(value);
    } else if (key.endsWith("Border") || key.endsWith("border")) {

      try {
        if (StringUtil.split(value, ",").size() == 4) {
          return new BorderUIResource.EmptyBorderUIResource(parseInsets(value));
        } else {
          return Class.forName(value).newInstance();
        }
      } catch (Exception e) {
        log(e);
      }
    } else {
      final Color color = parseColor(value);
      final Integer invVal = getInteger(value);
      final Boolean boolVal =
          "true".equals(value) ? Boolean.TRUE : "false".equals(value) ? Boolean.FALSE : null;
      Icon icon = value.startsWith("AllIcons.") ? IconLoader.getIcon(value) : null;
      if (icon == null && value.endsWith(".png")) {
        icon = IconLoader.findIcon(value, DarculaLaf.class, true);
      }
      if (color != null) {
        return new ColorUIResource(color);
      } else if (invVal != null) {
        return invVal;
      } else if (icon != null) {
        return new IconUIResource(icon);
      } else if (boolVal != null) {
        return boolVal;
      }
    }
    return value;
  }