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(); } void updateIcon { setIcon(imageIcon(loadImage2(on ? onImageID : offImageID))); } void set(bool value) swing { if (on != value) { on = value; updateIcon(); } } }