!759 static JTable questionsTable; p-substance { showFrame( hgrid( withTitle("Logic List", centerAndSouth( logicListTable(), vgrid( jbutton("Add care...", r { addCareDialog() }), jbutton("Add statement...", r { addStatementDialog() })))), withTitle("Questions", questionsTable = tableWithToolTips()))); onDoubleClickOrEnter(questionsTable, voidfunc(int row) { answerQuestion(row); }); tablePopupMenu(questionsTable, voidfunc(JPopupMenu menu, final int row) { menu.add(jmenuitem("Answer question...", r { answerQuestion(row) })); }); // TODO: thinker thread swingEvery(questionsTable, 1000, 50, r { if (tableShouldThink(questionsTable)) dataToTable_uneditable(questionsTable, makeQuestions()); }); } static L makeQuestions() { long time = now(); genLog_set(map(func(S s) { lastLine(s) }, gLogicList())); new L l; for (S care : gCares()) { if (gMatchStart(format("* is", care)) == null && gMatchStart(format("a * is", care)) == null && gMatchStart(format("the * is", care)) == null) l.add(format("What is *?", toUpper(care))); } done(time, "Making Questions"); ret l; } static S presetAnswer(S s) { new Matches m; if "what is *" ret format("* is ...", m.unq(0)); null; } static void answerQuestion(int row) { SS line = getTableLineAsMap(questionsTable, row); final S q = firstValue(line); if (empty(q)) ret; final JTextField textField = new JTextField(unnull(presetAnswer(q))); showForm( "Question", q, "Answer", textField, r { addToLogicList(fromLines(q, textField.getText())); }); }