sclass OptionalInputPanel { //DynModule module; JPanel panel; JTextField tfInput; JCheckBox cbInput; *(final DynModule module) { tfInput = jcenteredtextfield(); cbInput = jcheckbox(); onChangeAndNow(cbInput, r { setEnabled(tfInput, isChecked(cbInput)); module.updateMe(); }); onChange(tfInput, r { if (isChecked(cbInput)) module.updateMe() }); panel = westAndCenter(cbInput, tfInput); } JComponent panel() { ret panel; } JComponent swing() { ret panel; } S input() { bool myInput = isChecked(cbInput); fS s = trim(myInput ? getText(tfInput) : dm_getInterestingString()); if (!myInput) setText(tfInput, s); ret s; } }