JLabel具有多行和右对齐 [英] JLabel with multiple lines and alignment to the right
本文介绍了JLabel具有多行和右对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我搜索了很多帖子,发现 JLabel
支持HTML。
所以我可以做
$ b $ pre $ JLabel search = new JLabel(< html> Search< br /> By :其中/ HTML>中);
获取多行。以上代码将导致
搜索
作者:
然而,我想要的是类似于
Search
By:
在By:之前添加空格仅在窗口不可调整大小时才起作用和非常愚蠢的笑)。
任何人都可以告诉我如何修改这段代码,使其工作,因为我想吗?
解决方案
稍微简单的HTML比在@ MadProgrammer的答案中看到:
new JLabel(< html>< body style ='text-align:right' >搜索和LT峰; br>按:);
I searched through many posts and figured out that JLabel
supports HTML.
So I can do
JLabel search = new JLabel("<html>Search<br/> By:</html>");
to get multiple lines. Above code will result in
Search
By:
However, What I want is something like
Search
By:
Adding spaces before "By:" will work only when the window is not resizable(And very silly lol). Can anyone tell me how to modify this code to make it work as I wanted?
解决方案
Slightly simpler HTML than seen in @MadProgrammer's answer:
new JLabel("<html><body style='text-align: right'>Search<br>By:");
这篇关于JLabel具有多行和右对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文