将JScrollPane添加到JLabel [英] Add a JScrollPane to a JLabel

查看:86
本文介绍了将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

这篇关于将JScrollPane添加到JLabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆