2003/12/17 04:13:27
[org.ibex.core.git] / src / org / xwt / Box.java
index d6bb5f5..6f96cc2 100644 (file)
@@ -132,7 +132,7 @@ public final class Box extends JSScope implements Scheduler.Task {
 
     private String text = null;
     private Font font = DEFAULT_FONT; 
-    private Picture texture;
+    private Picture texture = null;
     private short strokewidth = 1;
     private int fillcolor = 0x00000000;
     private int strokecolor = 0xFF000000;
@@ -168,7 +168,13 @@ public final class Box extends JSScope implements Scheduler.Task {
 
 
     /** invoked when a resource needed to render ourselves finishes loading */
-    public void perform() {
+    public void perform() throws JSExn {
+        // as external events have occured, check the state of box
+        if (texture != null) {
+           if (texture.isLoaded) { minwidth = texture.width; minheight = texture.height; }
+           else { Res res = texture.res; texture = null; throw new JSExn("image not found: "+res); }
+        }
+
         MARK_REPACK;
         MARK_REFLOW;
         MARK_RESIZE;
@@ -572,23 +578,7 @@ public final class Box extends JSScope implements Scheduler.Task {
         }
         if (!(value instanceof Res)) return;
 
-
-        // FIXME
         texture = Picture.load((Res)value, this);
-        if (texture.isLoaded) {
-            minwidth = texture.width;
-            minheight = texture.height;
-            MARK_REFLOW;
-            dirty();
-            return;
-        }
-        texture = Picture.load((Res)value, new Scheduler.Task() { public void perform() {
-            // FIXME pass this instead of a new Task?
-            minwidth = texture.width;
-            minheight = texture.height;
-            Box b = Box.this; MARK_REFLOW_b;
-            dirty();
-        } });
     }
         
     private void mouseEvent(String name, Object value) {