将JScrollPane添加到JLabel
问题描述:
我似乎找不到如何将JScrollPane
添加到JLabel
的方法.我正在使用的JLabel
填充有长格式的HTML字符串.请帮忙.
I can't seem to find out how I can add a JScrollPane
to a JLabel
. The JLabel
that I'm using is populated with a long formatted HTML string. Please help.
area = new JLabel();
JScrollPane scroller = new JScrollPane(area,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
panel.add(scroller);
答
在JLabel中保存或显示长HTML格式的文本真的不是一个好主意,因为有可能,最好使用 JTextPane 和
Really not good idea to hold or display long Html formatted text in the JLabel, since is possible, better would be use JEditorPanes / JTextPanes, these JComponets support styled and html formatted text, Icons etc ... , examples for JTextPane and JEditorPane