Search code examples
javaswingalignmentjlabelright-to-left

Make JLabel html content right-to-left


I want to change a JLabel's content direction to be right to left.
The Jlabel content is HTML and I tested all these (& none of them worked!):

    lbl.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    lbl.setHorizontalTextPosition(JLabel.RIGHT);
    lbl.setHorizontalAlignment(JLabel.RIGHT);

How should I do that?

thanks


Solution

  • Use the div element to set the alignment and width of the text:

    <html><div align=right width=100px>text</div></html>