sclass JImageSwitch > JLabel { S onImageID, offImageID; S offToolTip, onToolTip; IVarWithNotify var; bool on; InstantNeverHideToolTip toolTip; *(S *onImageID, S *offImageID, IVarWithNotify *var) { toolTip = new InstantNeverHideToolTip(this); bindListenerToComponent(this, var, r { set(var!) }); on = var!; updateIcon(); onLeftClick(this, l0 flip); } selfType setToolTips(S onToolTip, S offToolTip) { this.onToolTip = onToolTip; this.offToolTip = offToolTip; updateIcon(); this; } void updateIcon { toolTip.setText(on ? onToolTip : offToolTip); setIcon(imageIcon(loadImage2_cached(on ? onImageID : offImageID))); } void flip { set(!on); } void set(bool value) swing { if (on != value) { on = value; updateIcon(); var.set(on); } } bool isOn() { ret on; } }