2 import java.awt.image.*;
9 static FontMetrics fnm;
12 static Color light_edge = Color.white;
13 static Color dark_edge = Color.black;
14 static Color body = Color.lightGray;
15 static Color body_hi = new Color(210, 210, 210);
16 static Color light_edge_hi = Color.white;
17 static Color dark_edge_hi = Color.darkGray;
18 static Color dark_bg = new Color(150, 150, 150);
19 static Color text = Color.black;
20 static Color light_bg = Color.white;
27 setFont(new Font("TimesRoman", Font.PLAIN, 8));
28 tk = Toolkit.getDefaultToolkit();
31 static boolean waitForImage(Image i)
33 MediaTracker mt = new MediaTracker(fr);
35 try { mt.waitForAll(); } catch(Exception e) { return false; }
36 return !mt.isErrorAny();
39 static boolean waitForImage(Image i, int w, int h)
41 MediaTracker mt = new MediaTracker(fr);
42 mt.addImage(i, w, h, 0);
43 try { mt.waitForAll(); } catch(Exception e) { return false; }
44 return !mt.isErrorAny();
47 static int getWidth(Image i)
50 return i.getWidth(fr);
53 static int getHeight(Image i)
56 return i.getHeight(fr);
59 static Image createImage(int w, int h)
61 return fr.createImage(w, h);
64 static Image createImage(ImageProducer p)
66 return fr.createImage(p);
69 static Object createObject(String name)
72 Class c = Class.forName(name);
73 return c.newInstance();
76 System.err.println("Failed to create object "+name+" : "+
77 e.getClass().getName());
83 /**Create a new instance of some object
85 static Object createObject(Object o)
87 try { return o.getClass().newInstance(); }
89 System.err.println("Failed to reproduce object "+o+" : "+
90 e.getClass().getName());
97 static void dottedRect(Graphics g, int x1, int y1,
98 int x2, int y2, int s)
101 if (x2 < x1) { t = x1; x1 = x2; x2 = t; }
102 if (y2 < y1) { t = y1; y1 = y2; y2 = t; }
103 for(i=x1; i<=x2; i+=s2)
104 g.drawLine(i, y1, i+s > x2 ? x2 : i+s, y1);
105 for(i=y1; i<=y2; i+=s2)
106 g.drawLine(x2, i, x2, i+s > y2 ? y2 : i+s);
107 for(i=x2; i>=x1; i-=s2)
108 g.drawLine(i, y2, i-s < x1 ? x1 : i-s, y2);
109 for(i=y2; i>=y1; i-=s2)
110 g.drawLine(x1, i, x1, i-s < y1 ? y1 : i-s);
113 static void recursiveLayout(Container c)
116 for(int i=0; i<c.countComponents(); i++) {
117 Component cc = c.getComponent(i);
118 if (cc instanceof Container)
119 recursiveLayout((Container)cc);
123 static void recursiveBackground(Component c, Color b)
125 if (c instanceof TextField || c instanceof Choice ||
126 c instanceof TextArea)
127 return; // leave these alone
129 if (c instanceof Container) {
130 Container cn = (Container)c;
131 for(int i=0; i<cn.countComponents(); i++)
132 recursiveBackground(cn.getComponent(i), b);
136 static void recursiveBody(Component c)
138 recursiveBackground(c, Util.body);
141 static void setFont(Font nf)
145 fnm = g.getFontMetrics();