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(); // Append some text doc.insertString(doc.getLength(), "some text", null); } }