More specifically, some Swing components support HTML. The 1st screen shot is from a JEditorPane, the rest use a JLabel. Many components use a JLabel as the default rendering component, such as tool tips, & default list & table renderers. JButton supports HTML partly. It will render incorrectly for a disabled button. JTextPane (styled text) also supports HTML, but JTextArea & JTextField (plain text) do not.
JWebBrowser geckoWebView = new JWebBrowser(JWebBrowser.useXULRunnerRuntime());
JWebBrowser webkitWebView = new JWebBrowser(JWebBrowser.useWebkitRuntime());
Native Swing allows to use an SWT Browser in Java Swing applications and to mix it with Swing widgets. It supports both WebKit and Xulrunner on several platforms (as well as IE on Windows). Make sure to have a libwebkit or libxulrunner that is compatible with the latest SWT implementation as described in the SWT FAQ The browser engine to use is controlled by an NSOption passed to JWebBrowser:
JWebBrowser geckoWebView = new JWebBrowser(JWebBrowser.useXULRunnerRuntime());
JWebBrowser webkitWebView = new JWebBrowser(JWebBrowser.useWebkitRuntime());
发布评论
评论(2)
Swing HTML 支持
Swing 组件(1) 将呈现 HTML 3.2 和基本样式。如果您控制 HTML,这可能是一个可行的选择。
HTML
请参阅我的回答此处,了解 2 个快速示例 的 HTML 图像
直接使用 Jar 文件中
使用相对引用
CSS
有关使用 CSS 在 Swing 组件中设置 HTML 样式的示例,请参阅以下问题的答案:
Java:HTML Swing,链接边距不起作用
JButtons
中的自动换行警告
JEditorPane
,其余的使用JLabel
。许多组件使用JLabel
作为默认渲染组件,例如工具提示、&标签。默认列表&表格渲染器。JButton
部分支持 HTML。对于禁用的按钮,它将错误地呈现。JTextPane
(样式文本)也支持 HTML,但JTextArea
&JTextField
(纯文本)不需要。另请参阅
有关详细信息,请参阅如何在 Swing 组件中使用 HTML 在 Java 教程中。
Swing HTML support
Swing components(1) will render HTML 3.2 and basic styles. It might be a viable option if you control the HTML.
HTML
See my answer here for 2 quick examples of using images in HTML
Direct from a Jar file
Using relative references
CSS
For examples of styling HTML in Swing components using CSS, see the answers to:
Java: HTML in Swing, link margin not working
Word Wrap in
JButtons
Caveat
JEditorPane
, the rest use aJLabel
. Many components use aJLabel
as the default rendering component, such as tool tips, & default list & table renderers.JButton
supports HTML partly. It will render incorrectly for a disabled button.JTextPane
(styled text) also supports HTML, butJTextArea
&JTextField
(plain text) do not.See Also
For more information see How to Use HTML in Swing Components in the Java Tutorial.
Native Swing 允许在 Java Swing 应用程序中使用 SWT 浏览器并将其与 Swing 小部件混合。它支持多个平台上的 WebKit 和 Xulrunner(以及 Windows 上的 IE)。确保拥有与最新 SWT 实现兼容的 libwebkit 或 libxulrunner,如 SWT 中所述常见问题解答
要使用的浏览器引擎由传递给 JWebBrowser 的 NSOption 控制:
Native Swing allows to use an SWT Browser in Java Swing applications and to mix it with Swing widgets. It supports both WebKit and Xulrunner on several platforms (as well as IE on Windows). Make sure to have a libwebkit or libxulrunner that is compatible with the latest SWT implementation as described in the SWT FAQ
The browser engine to use is controlled by an NSOption passed to JWebBrowser: