// f: (int w, int h) -> BufferedImage static ImageSurface jcanvas(O f) { ret jcanvas(f, 500); } static ImageSurface jcanvas(fO f, final int updateDelay) { assertAWTThread(); final new ImageSurface is; Runnable update = r { BufferedImage img = is.getImage(); int w = is.getWidth(), h = is.getHeight(); if (img.getWidth() != w || img.getHeight() != h) is.setImage(asBufferedImage(callF(f, w, h))); }; onResize(is, r { awtLater(is, updateDelay, update) }); bindToComponent(is, update); // first update ret is; }