- java.lang.Object
-
- javax.swing.plaf.basic.BasicHTML
-
public class BasicHTML extends Object
支持为swing组件提供html视图。 这将一个简单的html字符串转换为可以渲染html并提供必要的布局语义的javax.swing.text.View实现。- 从以下版本开始:
- 1.3
-
-
Field Summary
Fields Modifier and Type Field 描述 static StringdocumentBaseKey密钥存储为客户端属性,以指示相对引用被解析的基础。static StringpropertyKey作为JComponent的客户端属性存储时,用于html渲染器的键。
-
构造方法摘要
构造方法 Constructor 描述 BasicHTML()
-
方法摘要
所有方法 静态方法 具体的方法 Modifier and Type 方法 描述 static ViewcreateHTMLView(JComponent c, String html)为给定的组件和html的字符串创建一个html渲染器。static intgetHTMLBaseline(View view, int w, int h)返回html渲染器的基线。static booleanisHTMLString(String s)检查给定的字符串,看看它是否应该在支持html呈现的非文本组件中触发html渲染逻辑。static voidupdateRenderer(JComponent c, String text)将给定文本的HTML渲染存储到给定JComponent的客户端属性中。
-
-
-
字段详细信息
-
propertyKey
public static final String propertyKey
作为JComponent的客户端属性存储时,用于html渲染器的键。- 另请参见:
- Constant Field Values
-
documentBaseKey
public static final String documentBaseKey
密钥存储为客户端属性,以指示相对引用被解析的基础。 例如,让我们说您将图像保存在相对于代码路径的目录资源中,您将使用以下设置的基础:jComponent.putClientProperty(documentBaseKey, xxx.class.getResource("resources/"));- 另请参见:
- Constant Field Values
-
-
方法详细信息
-
createHTMLView
public static View createHTMLView(JComponent c, String html)
为给定的组件和html的字符串创建一个html渲染器。- 参数
-
c- 一个组件 -
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渲染逻辑。- 参数
-
s- 一个文本 - 结果
-
true如果给定的字符串应该在非文本组件中触发html呈现逻辑
-
updateRenderer
public static void updateRenderer(JComponent c, String text)
将给定文本的HTML渲染存储到给定JComponent的客户端属性中。 如果给定的文本不是HTML,则该属性将被清除任何渲染器。该方法对于静态(即共享)并且完全从JComponent获取状态的ComponentUI实现是有用的。
- 参数
-
c- 一个组件 -
text- 一个文本
-
-