sclass InputChooser implements Swingable { DynModule module; bool myInput; S ownInput; transient S input; transient JPanel panel; transient JTextField tfInput; transient JCheckBox cbInput; *() {} // only for persistence *(DynModule *module) {} S input() { ret input; } S _freshInput() { ret myInput ? ownInput : dm_getInterestingString(); } bool update() { S s = _freshInput(); if (neq(input, s)) { input = s; true; //dm_updateModule(); } false; } public JComponent visualize() { if (panel != null) ret panel; tfInput = jcenteredtextfield(); cbInput = setToolTip("Use my own input", jcheckbox()); onChangeAndNow(cbInput, r { setEnabled(tfInput, isChecked(cbInput)); myInput = isChecked(cbInput); module.updateMe() }); onChange(tfInput, r { if (myInput) { ownInput = getText(tfInput); module.updateMe(); } }); ret panel = westAndCenter(cbInput, tfInput); } }