简体   繁体   English

Java Swing组件中的HTML标签

[英]HTML Tag in Java Swing Components

Does adding HTML tags to Swing components, for example JLabels, make rendering of JFrame slow? 向Swing组件(例如JLabel)添加HTML标签是否会使JFrame的渲染变慢? I mean how is the performance of HTML rendering in Swing components? 我的意思是Swing组件中HTML呈现的性能如何?

Yes, depending on the complexity of your html. 是的,具体取决于您的html。

Actually when you have html in your jlabel, the BasicLabelUI uses a View to paint the label instead of simple paint logic. 实际上,当jlabel中包含html时,BasicLabelUI使用视图来绘制标签,而不是简单的绘制逻辑。 Now you can check various different implementations of View class to check how it affects you. 现在,您可以检查View类的各种不同实现,以检查它如何影响您。

You can read the code of BasicLabelUI.paint() for clarity. 为了清楚起见,您可以阅读BasicLabelUI.paint()的代码。

But for simple decorated html, I don't think you need to worry at all. 但是对于简单装饰的html,我根本不需要担心。

Swing's HTML rendering support uses many classes, therefore users on older systems might notice a delay the first time a component with HTML formatting is shown. Swing的HTML呈现支持使用许多类,因此,较旧系统的用户可能会在第一次显示具有HTML格式的组件时注意到延迟。 One way to avoid this delay is not to show the HTML-formatted component immediately and to create it (or another component that uses HTML) on a background thread. 避免这种延迟的一种方法是不立即显示HTML格式的组件,并在后台线程上创建它(或其他使用HTML的组件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM