sclass JImageSwitch > JLabel { S onImageID, offImageID; IVarWithNotify var; bool on; *(S onImageID, S *offImageID, IVarWithNotify var) { bindListenerToComponent(this, var, r { set(var!) }); on = var!; updateIcon(); onClick(this, -> switch); } void updateIcon { setIcon(imageIcon(loadImage2(on ? onImageID : offImageID))); } void switch { set(!on); } void set(bool value) swing { if (on != value) { on = value; updateIcon(); var.set(on); } } }