コード例 #1
0
 /**
  * Returns icon for the specified name.
  *
  * @param icon can be either String icon name, ImageIcon, Image, image File or image URL
  * @return icon for the specified name
  */
 public ImageIcon getIcon(final Object icon) {
   if (icon != null) {
     if (icon instanceof String) {
       try {
         if (nearClass != null) {
           return new ImageIcon(nearClass.getResource(path + icon + extension));
         } else {
           return new ImageIcon(new File(path, icon + extension).getAbsolutePath());
         }
       } catch (final Throwable e) {
         Log.warn("Unable to find menu icon for path: " + path + icon + extension, e);
         return null;
       }
     } else if (icon instanceof ImageIcon) {
       return (ImageIcon) icon;
     } else if (icon instanceof Image) {
       return new ImageIcon((Image) icon);
     } else if (icon instanceof File) {
       return new ImageIcon(((File) icon).getAbsolutePath());
     } else if (icon instanceof URL) {
       return new ImageIcon((URL) icon);
     } else {
       Log.warn("Unknown icon object type provided: " + icon);
       return null;
     }
   } else {
     return null;
   }
 }
コード例 #2
0
ファイル: WebComboBox.java プロジェクト: mgomesdfx/weblaf
 @Override
 public void updateUI() {
   if (getUI() == null || !(getUI() instanceof WebComboBoxUI)) {
     try {
       setUI((WebComboBoxUI) ReflectUtils.createInstance(WebLookAndFeel.comboBoxUI));
     } catch (final Throwable e) {
       Log.error(this, e);
       setUI(new WebComboBoxUI());
     }
   } else {
     setUI(getUI());
   }
 }
コード例 #3
0
ファイル: WebTable.java プロジェクト: ahmostin/weblaf
  @Override
  public void updateUI() {
    // Update table header UI
    if (getTableHeader() != null) {
      getTableHeader().updateUI();
    }

    // Update table scroll view and UI
    configureEnclosingScrollPaneUI();

    // Update table UI
    if (getUI() == null || !(getUI() instanceof WebTableUI)) {
      try {
        setUI((WebTableUI) ReflectUtils.createInstance(WebLookAndFeel.tableUI));
      } catch (final Throwable e) {
        Log.error(this, e);
        setUI(new WebTableUI());
      }
    } else {
      setUI(getUI());
    }
  }