I have JScrollPane
with JTextArea
inside it and I am trying to set the JTextArea\'s orientation from right to left so the text inside it will start
The following lines solved my problem:
jTextArea1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
jTextArea1.setText();
They serve to:
setComponentOrientation()
changes the orientation of the TextArea
; and,setText()
refreshes TextArea
immediately so it displays properly Simply setting ComponentOrientation
to RIGHT_TO_LEFT
is not sufficient by itself. repaint()
doesn't force the text to realign itself. A quick solution for me was to update the contents of the TextArea. That forced the text to realign itself.