!747 !actionListener { !awt { !pcall m { static JTable tbl; static int delay = 3000; static boolean withVMs = true; p { tbl = showTable("Bots Table"); getFrame(tbl).setBounds(10, 10, 400, 400); addTalkButton(); updateBotList(); installTimer(tbl, runnable { updateBotList(); }, delay); } static new MonoThread update; !include #1001434 // MonoThread static void updateBotList() { update.run(runnable { new L> bots; for (ProgramScan.Program p : quickBotScan()) { S botName = firstPartOfHelloString(p.helloString); boolean isVM = startsWithIgnoreCase(p.helloString, "This is a JavaX VM."); boolean shouldRecurse = startsWithIgnoreCase(botName, "Multi-Port") || isVM; if (withVMs || !isVM) bots.add(litlist(botName, "" + p.port)); if (shouldRecurse) pcall { Map subBots = (Map) unstructure(sendToLocalBot(p.port, "list bots")); for (Number vport : subBots.keySet()) bots.add(litlist(subBots.get(vport), p.port + "/" + vport)); } } sortByFirstColumn(bots); fillTableWithStrings(tbl, bots, "Hello message", "Port"); }); } static void addTalkButton() { awt { JButton btn = new JButton("Talk to bot"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pcall { S value = getSelectedColumn(tbl, 1); if (value != null) { startBot("User Request List Bot", "#1001706"); sendToLocalBot("User Request List Bot", "add *", "talk to bot " + quote(getSelectedColumn(tbl, 1))); startBot("Execute \"talk to bot\" commands bot.", "#1001709"); } } } }); addToWindow(tbl, btn); } } }