Libraryless. Click here for Pure Java version (2713L/18K/62K).
1 | !747 |
2 | !awt {
|
3 | !named thread |
4 | |
5 | m {
|
6 | static JLabel botName; |
7 | static JTextField tfDest, tfInput, tfOutput; |
8 | static JCheckBox cbSign; |
9 | static S currentPort; |
10 | |
11 | p {
|
12 | makeAndroid3("Quick Talk Window 2.");
|
13 | |
14 | showFrame("Quick Talk", stack(
|
15 | "Destination (bot name/address):", |
16 | tfDest = new JTextField("remote"),
|
17 | "Bot name:", |
18 | botName = new JLabel("(filled in later)"),
|
19 | cbSign = new JCheckBox("Sign"),
|
20 | "Your input (Enter to send):", |
21 | tfInput = new JTextField(), |
22 | "Bot answer:", |
23 | tfOutput = new JTextField())); |
24 | |
25 | onFocusLeave(tfDest, runnable { inquire(); });
|
26 | onEnter(tfDest, runnable { send(); });
|
27 | onEnter(tfInput, runnable { send(); });
|
28 | } |
29 | |
30 | static void setBotName(S name) {
|
31 | botName.setText(name); |
32 | } |
33 | |
34 | static void inquire() {
|
35 | go(false); |
36 | } |
37 | |
38 | static void send() {
|
39 | go(true); |
40 | } |
41 | |
42 | static void go(final boolean send) {
|
43 | tfOutput.setText("Connecting...");
|
44 | thread "sending" {
|
45 | try {
|
46 | final DialogIO io = findBot(tfDest.getText()); |
47 | if (io == null) {
|
48 | tfOutput.setText("Bot not found...");
|
49 | setBotName("");
|
50 | ret; |
51 | } |
52 | try {
|
53 | tfOutput.setText("Greeting...");
|
54 | |
55 | // get main name |
56 | S name = firstPartOfHelloString(io.readLine()); |
57 | // optionally get name of sub-bot |
58 | io.sendLine("your name");
|
59 | S line = io.readLine(); |
60 | if (!eq(line, "?")) |
61 | name = line; |
62 | setBotName(name); |
63 | |
64 | if (!send) {
|
65 | tfOutput.setText("");
|
66 | ret; |
67 | } |
68 | |
69 | line = tfInput.getText().trim(); |
70 | boolean sign = isChecked(cbSign); |
71 | if (line.startsWith("s/")) {
|
72 | line = line.substring(2); |
73 | sign = true; |
74 | } |
75 | if (sign) |
76 | line = format3("signed: *", signWithComputerID(line));
|
77 | |
78 | tfOutput.setText("Sending...");
|
79 | io.sendLine(line); |
80 | final S output = io.readLine(); |
81 | tfOutput.setText(output != null ? output : "?"); |
82 | } finally {
|
83 | io.close(); |
84 | } |
85 | } catch (Throwable e) {
|
86 | e.printStackTrace(); |
87 | tfOutput.setText(e.toString()); |
88 | } |
89 | } |
90 | } |
91 | } |
Began life as a copy of #1001760
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001787 |
| Snippet name: | Quick Talk Window 2 |
| Eternal ID of this version: | #1001787/1 |
| Text MD5: | e41b894b02bc9d42f0a296cf425bc481 |
| Transpilation MD5: | 4640dbaea1ce3418e019823959532ef9 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-11-19 21:14:38 |
| Source code size: | 2357 bytes / 91 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1054 / 1529 |
| Referenced in: | [show references] |