sclass Canvas extends ImageSurface { O makeImg; bool updating; *() { zoomable = false; } *(O makeImg) { this(); this.makeImg = makeImg; } void update() { updateCanvas(this, makeImg); } } static Canvas jcanvas() { ret jcanvas(null, 0); } // f: (int w, int h) -> BufferedImage static Canvas jcanvas(O f) { ret jcanvas(f, 0); // 100 } static Canvas jcanvas(fO f, final int updateDelay) { ret (Canvas) swing(func { final Canvas is = new Canvas(f); is.specialPurposed = true; final Runnable update = new Runnable { bool first = true; public void run { BufferedImage img = is.getImage(); int w = is.getWidth(), h = is.getHeight(); if (first || img.getWidth() != w || img.getHeight() != h) { updateCanvas(is, f); first = false; } } }; onResize(is, r { awtLater(is, updateDelay, update) }); bindToComponent(is, update); // first update ret is; }); }