!747 !awt { !named thread m { static JLabel botName; static JTextField tfDest, tfInput, tfOutput; static JCheckBox cbSign; static S currentPort; p { makeAndroid3("Quick Talk Window 2."); showFrame("Quick Talk", stack( "Destination (bot name/address):", tfDest = new JTextField("remote"), "Bot name:", botName = new JLabel("(filled in later)"), cbSign = new JCheckBox("Sign"), "Your input (Enter to send):", tfInput = new JTextField(), "Bot answer:", tfOutput = new JTextField())); onFocusLeave(tfDest, runnable { inquire(); }); onEnter(tfDest, runnable { send(); }); onEnter(tfInput, runnable { send(); }); } static void setBotName(S name) { botName.setText(name); } static void inquire() { go(false); } static void send() { go(true); } static void go(final boolean send) { tfOutput.setText("Connecting..."); thread "sending" { try { final DialogIO io = findBot(tfDest.getText()); if (io == null) { tfOutput.setText("Bot not found..."); setBotName(""); ret; } try { tfOutput.setText("Greeting..."); // get main name S name = firstPartOfHelloString(io.readLine()); // optionally get name of sub-bot io.sendLine("your name"); S line = io.readLine(); if (!eq(line, "?")) name = line; setBotName(name); if (!send) { tfOutput.setText(""); ret; } line = tfInput.getText().trim(); boolean sign = isChecked(cbSign); if (line.startsWith("s/")) { line = line.substring(2); sign = true; } if (sign) line = format3("signed: *", signWithComputerID(line)); tfOutput.setText("Sending..."); io.sendLine(line); final S output = io.readLine(); tfOutput.setText(output != null ? output : "?"); } finally { io.close(); } } catch (Throwable e) { e.printStackTrace(); tfOutput.setText(e.toString()); } } } }