Java Swing How to - Delete the first 5 characters








Question

We would like to know how to delete the first 5 characters.

Answer

// w  w w.  j ava2 s  . c o  m

import javax.swing.JTextArea;

public class Main {
  public static void main(String[] argv) {
    JTextArea ta = new JTextArea("Initial Text");
    int start = 0;
    int end = 5;
    ta.replaceRange(null, start, end);
  }
}