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).

!636
!modern // includes string ==
!actionListener {
!x619 // standard classes (LetterLayout, CenteredLine)
!multi-line strings

import java.awt.*;
import java.awt.event.*;
import java.util.List;

main {
  static JTextArea textArea;
  static JTextField tfCmd;
  static new L<S> history;
  static int historyIdx;
  
  psvm {
    JFrame frame = new JFrame("A JavaX Frame");
    
    JPanel panel = new JPanel(new BorderLayout());
    
    textArea = new JTextArea();
    panel.add(BorderLayout.CENTER, new JScrollPane(textArea));
    
    tfCmd = new JTextField();
    panel.add(BorderLayout.SOUTH, tfCmd);
    
    tfCmd.addActionListener(actionListener {
      tfCmd.selectAll();
      String cmd = tfCmd.getText();
      runCmd(cmd);
    });
    
    frame.addWindowListener(new WindowAdapter() {
      public void windowOpened(WindowEvent e) {
        tfCmd.requestFocus();
      }
    }); 
    
    frame.add(panel);
    frame.setBounds(100, 100, 500, 400);
    frame.setVisible(true);
    exitOnFrameClose(frame);
  }
  
  static void setText(S text) {
    if (text.equals(textArea.getText())) return;
    history.add(historyIdx++, textArea.getText());
    textArea.setText(text);
  }
  
  static void runCmd(String cmd) {
    if (cmd == "random chars") {
      S text = randomLetters(40);
      setText(text);
    } else if (cmd == "back") {
      if (historyIdx > 0)
        textArea.setText(history.get(--historyIdx));
    } else if (cmd == "hello") {
      setText("hello!");
    } else if (cmd == "java class") {
      setText([[%636
%modern

main {
  static O androidContext;
  static S programID;
  
  psvm {
  }
}
]].replace("%", "!"));
    }
  }
}

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: 688 / 708
Referenced in: #1000792 - Snippet search (Swing)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)