Reputation: 75
I want to insert a String
in a JTextField
. Something like-
myTextField.insert(text, position);
How can it be done? Is there any simple way to do this?
Upvotes: 5
Views: 2756
Reputation: 3870
You may do this-
jTextField.setText("This swing.");
jTextField.getDocument().insertString(5, "is", null);
And jTextField
will show-
This is swing.
Upvotes: 11