home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-10-04 | 1.4 KB | 73 lines |
- import java.awt.*;
-
-
- public class IEExtend
- {
- // The IE Extend class faciliates importing variables
- // in different formats
-
- // Modified for consistency by JAR
-
- public final static int strInt(String c, int def)
- {
- if(c!=null && c.length() > 0)
- {
- try
- {
- return Integer.parseInt(c);
- }
- catch(NumberFormatException e)
- {
- return def;
- }
- }
- return def;
- }
-
- public final static double strDouble(String c, double def)
- {
- if(c!=null && c.length() > 0)
- {
- try
- {
- return Double.valueOf(c).doubleValue();
- }
- catch(NumberFormatException e)
- {
- return def;
- }
- }
- return def;
- }
-
- public final static Color strColor(String c, Color def)
- {
- if(c == null)
- return def;
- return colorFromStr(c,def);
- }
-
- public final static Color colorFromStr(String c, Color def)
- {
- if(c.length() < 6)
- return def;
- String t;
- t = new String();
- t += c.charAt(0);
- t += c.charAt(1);
- int r = Integer.parseInt(t,16);
- t = new String();
- t += c.charAt(2);
- t += c.charAt(3);
- int g = Integer.parseInt(t,16);
- t = new String();
- t += c.charAt(4);
- t += c.charAt(5);
- int b = Integer.parseInt(t,16);
-
- return new Color(r,g,b);
- }
- }
-
-
-