!7 module SpeechRecogConfirmation > DynPrintLogAndButtons { start { onSpeechRecognized_withoutMyUtterancesAndTyped(voidfunc(fS s) { print("\nI heard: " + quote(s)); if (eq(s, "?")) { fS q = "Did you say anything?"; showButtons(q, "Yes", r { log(s, q, 'yes); whatDidYouSay(s); }, "No", r { log(s, q, 'no); print("Thanks"); }); } else { fS q = "Did you say that?"; showButtons(q, "Yes", r { log(s, q, 'yes); print("Thanks"); }, "No", r { log(s, q, 'no); whatDidYouSay(s); }); } }); } void log(S heard, S question, S answer) { print("> " + upper(answer)); logStructure(programLogFile(), litorderedmap(+heard, +question, +answer)); hideButtons(); } void whatDidYouSay(fS heard) { print("What did you say?"); final JTextField tf = jTextField(heard); showButtons(q, func -> JComponent { textFieldAndButton(tf, "is what I said", voidfunc(S corrected) { print("> I said " + quote(upper(corrected))); logStructure(programLogFile(), litorderedmap(+heard, +corrected)); hideButtons(); print("Thanks"); }) }); focus(tf); } void hideButtons { super.hideButtons(); dm_setTrayIcon_left(null); } void showButtons(S q, O... params) { print(q); super.showButtons(params); dm_setTrayIcon_left(jPreferredSizeToFixedSize(buttonsAsfillerlessHStack(singlePlusArray(jlabel(q), params)))); } void showButtons(S q, F0 makeButtons) { print(q); super.showButtons(makeButtons!); dm_setTrayIcon_left(jPreferredSizeToFixedSize(makeButtons!)); } }