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(); // Insert some text after the 5th character int pos = 5; doc.insertString(pos, "some text", null); } }