Transpiled version (2515L) is out of date.
!636 !modern // includes string == !actionListener { !x619 // standard classes (LetterLayout, CenteredLine) !multi-line strings !awt { main { static JList list; static JTextField tfCmd; static JLabel status; static S submittedInput; static int searchDelay = 100; static volatile boolean searching; !include #1000839 // PopupMenuHelper psvm { installHelloMessage("JavaX"); JFrame frame; try { frame = new JFrame("JavaX v3"); } catch (HeadlessException e) { System.out.println("We're headless..."); return; } JPanel panel = new JPanel(new BorderLayout()); list = new JList(); panel.add(BorderLayout.CENTER, new JScrollPane(list)); new PopupMenuHelper() { void fillMenu() { JMenuItem mi; int idx = list.locationToIndex(point); final String item = cast list.getModel().getElementAt(idx); list.setSelectedIndex(idx); mi = new JMenuItem("RUN! (warning: no questions asked)"); mi.addActionListener(actionListener { run(item); }); menu.add(mi); mi = new JMenuItem("Run with arguments..."); mi.addActionListener(actionListener { runWithArguments(item); }); menu.add(mi); } }.install(list); tfCmd = new JTextField(); panel.add(BorderLayout.NORTH, withLabel("Search term:", tfCmd)); status = new JLabel(" "); panel.add(BorderLayout.SOUTH, status); tfCmd.addActionListener(actionListener { tfCmd.selectAll(); final String cmd = tfCmd.getText(); thread { try { tfCmd.setEnabled(false); search(cmd); } finally { tfCmd.setEnabled(true); } } }); frame.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { tfCmd.requestFocus(); } }); installTimer(tfCmd, new Runnable() { String lastContents; boolean autoSearchOn = true; public void run() { String text = tfCmd.getText(); if (text.equals(lastContents)) { if (!text.equals(submittedInput) && autoSearchOn && !searching) doIt(); } else lastContents = text; } }, searchDelay); frame.add(panel); frame.setBounds(100, 100, 500, 400); frame.setVisible(true); exitOnFrameClose(frame); search(""); } static void search(String cmd) ctex { searching = true; try { status("Searching " + quote(cmd) + "..."); if (cmd == "") cmd = "%"; S page = loadPage("http://tinybrain.de:8080/tb/search.php?q=" + urlencode(cmd + " type:runnable")); Matcher m = Pattern.compile(">(#\\d+)</a> - (.*?)<br>").matcher(page); final new DefaultListModel<S> model; while (m.find()) model.addElement(htmldecode(m.group(1) + " - " + m.group(2))); awt { list.setModel(model); status("Found " + model.size() + " runnable(s)."); tfCmd.requestFocus(); } } finally { searching = false; } } static void status(final S s) { awt { status.setText(s); } } static void run(S item) { int i = item.indexOf(' '); if (i >= 0) item = item.substring(0, i); long id = parseSnippetID(item); print("Running " + id); nohupJavax("#1000874".substring(1) + " " + id); } static void runWithArguments(S item) { // TODO: run a dialog for that } static void doIt() { submittedInput = tfCmd.getText(); thread { search(submittedInput); } } }
Began life as a copy of #1000825
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: | #1000876 |
Snippet name: | Outdated version of swing-start |
Eternal ID of this version: | #1000876/1 |
Text MD5: | 18a35eeedbeb7673c72cb93c86c8ff65 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-13 15:07:12 |
Source code size: | 3741 bytes / 139 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 623 / 725 |
Referenced in: | #3000188 - Answer for stefanreich(>> t search) #3000190 - Answer for stefanreich(>> t 20 questions) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |