Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

58
LINES

< > BotCompany Repo | #1000792 // Snippet search (Swing)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (319L/4K/12K).

1  
!636
2  
!modern // includes string ==
3  
!actionListener {
4  
!x619 // standard classes (LetterLayout, CenteredLine)
5  
!multi-line strings
6  
7  
import java.awt.*;
8  
import java.awt.event.*;
9  
import java.util.List;
10  
11  
main {
12  
  static JList list;
13  
  static JTextField tfCmd;
14  
  static new L<S> history;
15  
  static int historyIdx;
16  
  
17  
  psvm {
18  
    JFrame frame = new JFrame("Snippet Search");
19  
    
20  
    JPanel panel = new JPanel(new BorderLayout());
21  
    
22  
    list = new JList();
23  
    panel.add(BorderLayout.CENTER, new JScrollPane(list));
24  
    
25  
    tfCmd = new JTextField();
26  
    panel.add(BorderLayout.NORTH, tfCmd);
27  
    
28  
    tfCmd.addActionListener(actionListener {
29  
      tfCmd.selectAll();
30  
      String cmd = tfCmd.getText();
31  
      runCmd(cmd);
32  
    });
33  
    
34  
    frame.addWindowListener(new WindowAdapter() {
35  
      public void windowOpened(WindowEvent e) {
36  
        tfCmd.requestFocus();
37  
      }
38  
    }); 
39  
    
40  
    frame.add(panel);
41  
    frame.setBounds(100, 100, 500, 400);
42  
    frame.setVisible(true);
43  
    exitOnFrameClose(frame);
44  
    
45  
    //runCmd(""); // find latest
46  
  }
47  
  
48  
  static void runCmd(String cmd) ctex {
49  
    if (cmd == "") cmd = "%";
50  
    S page = loadPage("http://tinybrain.de:8080/tb/search.php?q=" + urlencode(cmd));
51  
    Matcher m = Pattern.compile(">(#\\d+)</a> - (.*?)<br>").matcher(page);
52  
    
53  
    new DefaultListModel<S> model;
54  
    while (m.find())
55  
      model.addElement(htmldecode(m.group(1) + " - " + m.group(2)));
56  
    list.setModel(model);
57  
  }
58  
}

Author comment

Began life as a copy of #1000690

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: #1000792
Snippet name: Snippet search (Swing)
Eternal ID of this version: #1000792/1
Text MD5: 0478c6241e406ae24f2c94e6e08f49d0
Transpilation MD5: ae33065e6ee53e7dee55285b5598df2e
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-28 12:12:51
Source code size: 1492 bytes / 58 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1410 / 804
Referenced in: [show references]