I want to align the text in a TextArea
to the right. I tried the following code:
Form form = new Form();
TextArea textArea = new TextArea("Some Arabic text ...");
textArea.setRTL(true);
textArea.setAlignment(RIGHT);
form.addComponent(textArea);
The result was just moving the scroll to left,
But the text is still not aligned RIGHT
,
check the image below:
So how to align the content to the RIGHT
?
It may sound crazy for the first instance :) but setting the alignment to
TextArea.LEFT
solved the issue and now it'sRIGHT
aligned !Setting it to
LEFT
makes the displayed textRIGHT
aligned !Or by removing the
textArea.setRTL(true)
which is mirroring the displayFor those who are interested in more complicated details when it's set to RTL:
the
paint
method ofTextArea
class isAnd
drawTextArea
method inDefaultLookAndFeel
is as follows:Unfortunately
TextArea.RIGHT
value is 3But when calling
ta.getAbsoluteAlignment()
it returns 1 (despite that the object's alignment is set by code toTextArea.RIGHT
!!)Meanwhile
TextArea.Left
value is 1That's why it matched the value in the switch and was aligned to
RIGHT
BTW, if you set
it will also be wrong, because
Component.RIGHT
outside the paint method has the value 3 not 1 !