posted 17 years ago
I have a program where you click a button and it adds a character to a JTextField. You can keep clicking on the button and it will add random characters to it.
What I am trying to do is when a new character is inserted, I want it to be inserted from the left side not added on to the right. Here's an example
Say I have the following text in a JTextField:
a b c d
and I want to insert 'e'. By default 'e' will be added so it looks like this
a b c d e
I want it to look like this
e a b c d
where the text is inserted from the left hand side. I have tried setting the caretposition for that JTextField to zero each time a click event takes place, but that didn't work. Any help is appreciated.