JavaTM 2 Platform
Standard Ed. 6

javax.swing.plaf.basic
类 BasicHTML

java.lang.Object
  继承者 javax.swing.plaf.basic.BasicHTML

public class BasicHTML
extends Object

支持为 swing 组件提供 html 视图。它将简单的 html 字符串转换为 javax.swing.text.View 实现,它能呈现 html 并提供必需的布局语义。

从以下版本开始:
1.3

字段摘要
static String documentBaseKey
          存储为客户端属性以指示用作解析相关引用的基址的键。
static String propertyKey
          存储为 JComponent 的客户端属性时用于 html 渲染器的键。
 
构造方法摘要
BasicHTML()
           
 
方法摘要
static View createHTMLView(JComponent c, String html)
          创建给定组件和 html 字符串的 html 渲染器。
static int getHTMLBaseline(View view, int w, int h)
          返回 html 渲染器的基线。
static boolean isHTMLString(String s)
          检查给定字符串以查看它是否应该在支持 html 呈现的非文本组件中触发 html 呈现逻辑。
static void updateRenderer(JComponent c, String text)
          将给定文本的 HTML 渲染器隐藏在给定 JComponent 的客户端属性中。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

propertyKey

public static final String propertyKey
存储为 JComponent 的客户端属性时用于 html 渲染器的键。

另请参见:
常量字段值

documentBaseKey

public static final String documentBaseKey
存储为客户端属性以指示用作解析相关引用的基址的键。例如,假设要将图像保存在相对于代码路径的目录资源中,应该使用以下代码设置基址:
   jComponent.putClientProperty(documentBaseKey,
                                xxx.class.getResource("resources/"));
 

另请参见:
常量字段值
构造方法详细信息

BasicHTML

public BasicHTML()
方法详细信息

createHTMLView

public static View createHTMLView(JComponent c,
                                  String html)
创建给定组件和 html 字符串的 html 渲染器。


getHTMLBaseline

public static int getHTMLBaseline(View view,
                                  int w,
                                  int h)
返回 html 渲染器的基线。

参数:
view - 为其获取基线的视图
w - 为其获取基线的宽度
h - 为其获取基线的高度
返回:
基线;或者返回值 < 0,指示没有合理的基线
抛出:
IllegalArgumentException - 如果宽度或高度 < 0
从以下版本开始:
1.6
另请参见:
FontMetrics, JComponent.getBaseline(int,int)

isHTMLString

public static boolean isHTMLString(String s)
检查给定字符串以查看它是否应该在支持 html 呈现的非文本组件中触发 html 呈现逻辑。


updateRenderer

public static void updateRenderer(JComponent c,
                                  String text)
将给定文本的 HTML 渲染器隐藏在给定 JComponent 的客户端属性中。如果给定文本是非 HTML,则属性中的所有渲染器都将被清除掉。

此方法对于静态(即共享)ComponentUI 实现十分有用,可以完全从 JComponent 中获取其状态。


JavaTM 2 Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策