Example #1
0
  @Override
  public void actionPerformed(ActionEvent e) {
    switch (e.getActionCommand()) {
      case "Open":
        try {
          String filename = fileHelper.fileChoose();
          if (!filename.equals("")) fileHelper.open(filename);

        } catch (IOException e1) {
          e1.printStackTrace();
        }
        codeArea.setText(fileHelper.getReadIn());
        break;
      case "Save":
        try {
          String filename = fileHelper.fileChoose();
          fileHelper.setSaved(codeArea.getText());
          if (!filename.equals("")) fileHelper.save(filename);

        } catch (IOException e1) {
          e1.printStackTrace();
        }
        break;
      case "Build":
        new BuildFrame(codeArea.getText());
        break;
    }
  }
Example #2
0
  private void addDefaultTextArea() {
    codeArea = new CodeEditor();
    codeArea.setFont(new Font("dialog", 0, 15));
    codeArea.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub
            if (e.getKeyChar() == '\n') {
              row++;
              col = 0;
            } else {
              col++;
            }
            updateStatus(row, col);
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub

          }
        });
    JScrollPane codePanel = new JScrollPane(codeArea);
    add(codePanel);
    status = new JTextField();
    status.setEnabled(false);
    add(status, BorderLayout.SOUTH);
    updateStatus(1, 1);
  }