asclass ImageSurfaceMouseHandler > MouseAdapter is AutoCloseable { ImageSurface is; void register(ImageSurface is) { this.is = is; is.tools.add(this); is.addMouseListener(this); is.addMouseMotionListener(this); } close { if (is == null) ret; is.tools.remove(this); is.removeMouseListener(this); is.removeMouseMotionListener(this); is = null; } }