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

75
LINES

< > BotCompany Repo | #1000690 // IDE (developing)

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

Libraryless. Click here for Pure Java version (92L/1K/4K).

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 JTextArea textArea;
13  
  static JTextField tfCmd;
14  
  static new L<S> history;
15  
  static int historyIdx;
16  
  
17  
  psvm {
18  
    JFrame frame = new JFrame("A JavaX Frame");
19  
    
20  
    JPanel panel = new JPanel(new BorderLayout());
21  
    
22  
    textArea = new JTextArea();
23  
    panel.add(BorderLayout.CENTER, new JScrollPane(textArea));
24  
    
25  
    tfCmd = new JTextField();
26  
    panel.add(BorderLayout.SOUTH, 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  
  
46  
  static void setText(S text) {
47  
    if (text.equals(textArea.getText())) return;
48  
    history.add(historyIdx++, textArea.getText());
49  
    textArea.setText(text);
50  
  }
51  
  
52  
  static void runCmd(String cmd) {
53  
    if (cmd == "random chars") {
54  
      S text = randomLetters(40);
55  
      setText(text);
56  
    } else if (cmd == "back") {
57  
      if (historyIdx > 0)
58  
        textArea.setText(history.get(--historyIdx));
59  
    } else if (cmd == "hello") {
60  
      setText("hello!");
61  
    } else if (cmd == "java class") {
62  
      setText([[%636
63  
%modern
64  
65  
main {
66  
  static O androidContext;
67  
  static S programID;
68  
  
69  
  psvm {
70  
  }
71  
}
72  
]].replace("%", "!"));
73  
    }
74  
  }
75  
}

Author comment

Began life as a copy of #1000682

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: #1000690
Snippet name: IDE (developing)
Eternal ID of this version: #1000690/1
Text MD5: 17bf4784a4791f52ff60dcb41a582dfa
Transpilation MD5: 04509e03b8234036350eb1248ffbe20d
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-23 14:59:28
Source code size: 1734 bytes / 75 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 695 / 719
Referenced in: [show references]