Java tutorial
import javax.swing.JTextField; import javax.swing.text.Document; import javax.swing.text.JTextComponent; public class Main { public static void main(String[] argv) throws Exception { JTextComponent textComp = new JTextField("Initial Text"); Document doc = textComp.getDocument(); // Delete the first 5 characters int pos = 0; int len = 5; doc.remove(pos, len); } }