psmith      2003/12/09 16:01:23

  Modified:    src/java/org/apache/log4j/chainsaw/icons
                        LevelIconFactory.java
  Log:
  Fixed a bug found by Scott Deboy where the new
  GTK L&F doesn't seem to know how to find some
  basic warn/info/error icons.
  
  Modified to use the Metal L&F class to retrieve the icon
  if it can't find it.
  
  I am sure this is because I really do not understand the proper
  way to get access to standard swing icons.  If anyone
  knows, please point the way.
  
  Revision  Changes    Path
  1.2       +15 -3     
jakarta-log4j/src/java/org/apache/log4j/chainsaw/icons/LevelIconFactory.java
  
  Index: LevelIconFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/icons/LevelIconFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LevelIconFactory.java     5 Sep 2003 06:07:26 -0000       1.1
  +++ LevelIconFactory.java     10 Dec 2003 00:01:23 -0000      1.2
  @@ -53,11 +53,15 @@
   
   import java.awt.Image;
   
  +import java.net.URL;
   import java.util.HashMap;
   import java.util.Map;
   
   import javax.swing.ImageIcon;
  +import javax.swing.LookAndFeel;
   import javax.swing.UIManager;
  +import javax.swing.UIManager.LookAndFeelInfo;
  +import javax.swing.plaf.metal.MetalLookAndFeel;
   
   
   /**
  @@ -73,10 +77,18 @@
       Level[] levels = new Level[] { Level.WARN, Level.INFO, Level.ERROR };
   
       for (int i = 0; i < iconLabels.length; i++) {
  +      URL resourceURL = UIManager.getLookAndFeel().getClass().getResource(
  +          "icons/" + iconFileNames[i]);
  +      if(resourceURL == null) {
  +        resourceURL = MetalLookAndFeel.class.getResource(
  +          "icons/" + iconFileNames[i]);
  +      }
  +      if(resourceURL == null) {
  +        throw new IllegalStateException("Was unable to locate an L&F icon using 
either the current L&F or the cross platform L&F.");
  +      }
  +      
         final ImageIcon icon =
  -        new ImageIcon(
  -          UIManager.getLookAndFeel().getClass().getResource(
  -            "icons/" + iconFileNames[i]));
  +        new ImageIcon(resourceURL);
         double scalex = .5;
         double scaley = .5;
         final int newWidth = (int) (scalex * icon.getIconWidth());
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to