I'm creating small game for children to teach maths.For that I need JTextField
to operate right to left. It mean that If I type "A" then "B" using keyboard, in JTextField
it should be display like "BA". I think you guys can get a idea now.
Thanks in advance. :)
Asked
Active
Viewed 4,295 times
2

Mr. Polywhirl
- 42,981
- 12
- 84
- 132

FxMax
- 472
- 1
- 5
- 9
-
possible duplicate of [How to set the orientation of JTextArea from right to left (inside JOptionPane)](http://stackoverflow.com/questions/6475320/how-to-set-the-orientation-of-jtextarea-from-right-to-left-inside-joptionpane) – Paco Abato Feb 02 '15 at 13:12
-
textField.setCaretPosition(0); Try this – Subhan Feb 02 '15 at 13:14
2 Answers
7
Use setComponentOrientation
method of JTextComponent Class
textField.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

Neeraj Jain
- 7,643
- 6
- 34
- 62
-
Actually this is not what I want.I want to type text reverse. :) any Help? – FxMax Feb 02 '15 at 16:10
-
If I type "A" then "B" then "C" in textfield it should display like "CBA" – FxMax Feb 02 '15 at 16:14
0
What you ask for is not a feature of JTextfield or its parents.
One way you can get what you want is to use Apache Commons Lang library and class StringUtils.reverse("flip") -> "pilf".

Avec
- 1,626
- 21
- 31