开发者

Set JLabel Alignment right-left

开发者 https://www.devze.com 2023-04-07 11:57 出处:网络
I have a JPanel that separated to 2 blocks, in south block (layout) I have add a JLabel, In the label I want to Insert a string with this rule: (Name, Date, Time, In/Out)

I have a JPanel that separated to 2 blocks, in south block (layout) I have add a JLabel, In the label I want to Insert a string with this rule: (Name, Date, Time, In/Out)

If my name was written in English everything was fine the problem appeared when I wrote the name in some Unicode language like Farsi, then the alignment not working as expected. I attach 2 sample:

Righ开发者_开发问答t one:

Set JLabel Alignment right-left

Wrong one:

Set JLabel Alignment right-left


You can create two different labels next to each other. One for the name and one for the remaining part. This way, the alignment of the name label won't affect the alignment of the other label.


Try using Component.setComponentOrientation() on the label to force it to left-to-right order.

0

精彩评论

暂无评论...
验证码 换一张
取 消