sclass VolatileImageSurfaceDemo is Swingable { new Timings timings; JLabel lblTimings = jlabel(); JVolatileImageSurface surface; settable Renderable renderable = (g, w, h) -> { S mode = surface.volatileMode() ? " [vol]" : ""; timings.do("background" + mode, -> { g.setColor(Color.green); g.fillRect(0, 0, w, h); }); timings.do("circle" + mode, -> fillCircle(g, w/2, h/2, w/4, Color.blue)); }; visualize { surface = new JVolatileImageSurface(renderable); awtDoEvery(lblTimings, 1.0, -> lblTimings.setText(timings.toStringSingleLine())); JCheckBox cbVolatileMode = jCheckBox(true, "Use volatile image", b -> surface.setVolatileMode(b)); ret northCenterAndSouthWithMargin( jcenteredline(cbVolatileMode), surface, lblTimings); } }