JLabel with multiple lines and alignment to the right

前端 未结 3 513
执笔经年
执笔经年 2020-12-07 02:29

I searched through many posts and figured out that JLabel supports HTML. So I can do

JLabel search  = new JLabel(\"Search
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 03:14

    There are a number of ways you might achieve this, one of the safer ways might be to use a

    and aligning both cells to the right...

    Label wrapped in table

    JLabel label = new JLabel(
                    "
    " + "" + "
    Search
    By:
    " );

    This overcomes issues with differences between fonts and font rendering on different platforms

提交回复
热议问题