目录搜索
文字
分享


JavaTM 2 Platform
Standard Ed. 6

javax.swing.border
类 TitledBorder

1

2

3

java.lang.Object

  <img src="../../../resources/inherit.gif" alt="继承者 ">javax.swing.border.AbstractBorder

      <img src="../../../resources/inherit.gif" alt="继承者 "><b>javax.swing.border.TitledBorder</b>

所有已实现的接口:
Serializable, Border
直接已知子类:
BorderUIResource.TitledBorderUIResource

1

public class <b>TitledBorder</b>

extends AbstractBorder

该类实现在指定位置以指定对齐方式显示字符串标题的任意边框。

如果构造方法中未指定边框、字体或颜色属性,也没有调用相应的设置方法来设置这些属性值,则当前外观将按照“默认表”中的如下属性名称定义属性值:

  • "TitledBorder.border"
  • "TitledBorder.font"
  • "TitledBorder.titleColor"

警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder


字段摘要
static int ABOVE_BOTTOM
          将标题置于边框底端线的顶部。
static int ABOVE_TOP
          将标题置于边框顶端线的上部。
static int BELOW_BOTTOM
          将标题置于边框底端线的底部。
static int BELOW_TOP
          将标题置于边框顶端线的底部。
protected  Border border
           
static int BOTTOM
          将标题置于边框底端线的中部。
static int CENTER
          将标题文本置于边框线的中心。
static int DEFAULT_JUSTIFICATION
          标题文本使用默认的对齐方式。
static int DEFAULT_POSITION
          标题文本使用默认的垂直方向。
protected static int EDGE_SPACING
           
static int LEADING
          从左到右排列时将标题文本置于边框线的左边,从右到左排列时将标题文本置于边框线的右边。
static int LEFT
          将标题文本置于边框线的左边。
static int RIGHT
          将标题文本置于边框线的右边。
protected static int TEXT_INSET_H
           
protected static int TEXT_SPACING
           
protected  String title
           
protected  Color titleColor
           
protected  Font titleFont
           
protected  int titleJustification
           
protected  int titlePosition
           
static int TOP
          将标题置于边框顶端线的中部。
static int TRAILING
          从左到右排列时将标题文本置于边框线的右边,从右到左排列时将标题文本置于边框线的左边。
 
构造方法摘要
TitledBorder(Border border)
          创建具有指定边框和空标题的 TitledBorder 实例。
TitledBorder(Border border, String title)
          创建具有指定边框和标题的 TitledBorder 实例。
TitledBorder(Border border, String title, int titleJustification, int titlePosition)
          用指定的边框、标题、标题对齐方式和标题位置创建 TitledBorder 实例。
TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont)
          用指定的边框、标题、标题对齐方式、标题位置和标题字体创建 TitledBorder 实例。
TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)
          用指定的边框、标题、标题对齐方式、标题位置、标题字体和标题颜色创建 TitledBorder 实例。
TitledBorder(String title)
          创建 TitledBorder 实例。
 
方法摘要
 int getBaseline(Component c, int width, int height)
          返回基线。
 Component.BaselineResizeBehavior getBaselineResizeBehavior(Component c)
          返回一个枚举,指示该边框的基线如何随大小的改变而发生更改。
 Border getBorder()
          返回带标题边框的边框。
 Insets getBorderInsets(Component c)
          返回边框的 insets。
 Insets getBorderInsets(Component c, Insets insets)
          用此边框的当前 Insets 重新初始化 insets 参数。
protected  Font getFont(Component c)
           
 Dimension getMinimumSize(Component c)
          返回此边框完全显示边框和标题所需的最小大小。
 String getTitle()
          返回带标题边框的标题。
 Color getTitleColor()
          返回带标题边框的标题颜色。
 Font getTitleFont()
          返回带标题边框的标题字体。
 int getTitleJustification()
          返回带标题边框的标题对齐方式。
 int getTitlePosition()
          返回带标题边框的标题位置。
 boolean isBorderOpaque()
          返回边框是否透明。
 void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
          按照指定的位置和大小为指定的组件绘制边框。
 void setBorder(Border border)
          设置带标题边框的边框。
 void setTitle(String title)
          设置带标题边框的标题。
 void setTitleColor(Color titleColor)
          设置带标题边框的标题颜色。
 void setTitleFont(Font titleFont)
          设置带标题边框的标题字体。
 void setTitleJustification(int titleJustification)
          设置带标题边框的标题对齐方式。
 void setTitlePosition(int titlePosition)
          设置带标题边框的标题位置。
 
从类 javax.swing.border.AbstractBorder 继承的方法
getInteriorRectangle, getInteriorRectangle
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

title

1

protected String <b>title</b>


border

1

protected Border <b>border</b>


titlePosition

1

protected int <b>titlePosition</b>


titleJustification

1

protected int <b>titleJustification</b>


titleFont

1

protected Font <b>titleFont</b>


titleColor

1

protected Color <b>titleColor</b>


DEFAULT_POSITION

1

public static final int <b>DEFAULT_POSITION</b>

标题文本使用默认的垂直方向。

另请参见:
常量字段值

ABOVE_TOP

1

public static final int <b>ABOVE_TOP</b>

将标题置于边框顶端线的上部。

另请参见:
常量字段值

TOP

1

public static final int <b>TOP</b>

将标题置于边框顶端线的中部。

另请参见:
常量字段值

BELOW_TOP

1

public static final int <b>BELOW_TOP</b>

将标题置于边框顶端线的底部。

另请参见:
常量字段值

ABOVE_BOTTOM

1

public static final int <b>ABOVE_BOTTOM</b>

将标题置于边框底端线的顶部。

另请参见:
常量字段值

BOTTOM

1

public static final int <b>BOTTOM</b>

将标题置于边框底端线的中部。

另请参见:
常量字段值

BELOW_BOTTOM

1

public static final int <b>BELOW_BOTTOM</b>

将标题置于边框底端线的底部。

另请参见:
常量字段值

DEFAULT_JUSTIFICATION

1

public static final int <b>DEFAULT_JUSTIFICATION</b>

标题文本使用默认的对齐方式。

另请参见:
常量字段值

LEFT

1

public static final int <b>LEFT</b>

将标题文本置于边框线的左边。

另请参见:
常量字段值

CENTER

1

public static final int <b>CENTER</b>

将标题文本置于边框线的中心。

另请参见:
常量字段值

RIGHT

1

public static final int <b>RIGHT</b>

将标题文本置于边框线的右边。

另请参见:
常量字段值

LEADING

1

public static final int <b>LEADING</b>

从左到右排列时将标题文本置于边框线的左边,从右到左排列时将标题文本置于边框线的右边。

另请参见:
常量字段值

TRAILING

1

public static final int <b>TRAILING</b>

从左到右排列时将标题文本置于边框线的右边,从右到左排列时将标题文本置于边框线的左边。

另请参见:
常量字段值

EDGE_SPACING

1

protected static final int <b>EDGE_SPACING</b>

另请参见:
常量字段值

TEXT_SPACING

1

protected static final int <b>TEXT_SPACING</b>

另请参见:
常量字段值

TEXT_INSET_H

1

protected static final int <b>TEXT_INSET_H</b>

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

TitledBorder

1

public <b>TitledBorder</b>(String title)

创建 TitledBorder 实例。

参数:
title - 边框应显示的标题

TitledBorder

1

public <b>TitledBorder</b>(Border border)

创建具有指定边框和空标题的 TitledBorder 实例。

参数:
border - 边框

TitledBorder

1

2

public <b>TitledBorder</b>(Border border,

                    String title)

创建具有指定边框和标题的 TitledBorder 实例。

参数:
border - 边框
title - 边框应显示的标题

TitledBorder

1

2

3

4

public <b>TitledBorder</b>(Border border,

                    String title,

                    int titleJustification,

                    int titlePosition)

用指定的边框、标题、标题对齐方式和标题位置创建 TitledBorder 实例。

参数:
border - 边框
title - 边框应显示的标题
titleJustification - 标题的对齐方式
titlePosition - 标题的位置

TitledBorder

1

2

3

4

5

public <b>TitledBorder</b>(Border border,

                    String title,

                    int titleJustification,

                    int titlePosition,

                    Font titleFont)

用指定的边框、标题、标题对齐方式、标题位置和标题字体创建 TitledBorder 实例。

参数:
border - 边框
title - 边框应显示的标题
titleJustification - 标题的对齐方式
titlePosition - 标题的位置
titleFont - 显示标题的字体

TitledBorder

1

2

3

4

5

6

public <b>TitledBorder</b>(Border border,

                    String title,

                    int titleJustification,

                    int titlePosition,

                    Font titleFont,

                    Color titleColor)

用指定的边框、标题、标题对齐方式、标题位置、标题字体和标题颜色创建 TitledBorder 实例。

参数:
border - 边框
title - 边框应显示的标题
titleJustification - 标题的对齐方式
titlePosition - 标题的位置
titleFont - 标题的字体
titleColor - 标题的颜色
方法详细信息

paintBorder

1

2

3

4

5

6

public void <b>paintBorder</b>(Component c,

                        Graphics g,

                        int x,

                        int y,

                        int width,

                        int height)

按照指定的位置和大小为指定的组件绘制边框。

指定者:
接口 Border 中的 paintBorder
覆盖:
AbstractBorder 中的 paintBorder
参数:
c - 要为其绘制边框的组件
g - 绘制的图形
x - 所绘制边框的 x 坐标位置
y - 所绘制边框的 y 坐标位置
width - 所绘制边框的宽度
height - 所绘制边框的高度

getBorderInsets

1

public Insets <b>getBorderInsets</b>(Component c)

返回边框的 insets。

指定者:
接口 Border 中的 getBorderInsets
覆盖:
AbstractBorder 中的 getBorderInsets
参数:
c - 要应用此边框 insets 值的组件
返回:
已初始化为 0 的新 Insets 对象

getBorderInsets

1

2

public Insets <b>getBorderInsets</b>(Component c,

                              Insets insets)

用此边框的当前 Insets 重新初始化 insets 参数。

覆盖:
AbstractBorder 中的 getBorderInsets
参数:
c - 应用此边框 insets 值的组件
insets - 要重新初始化的对象
返回:
insets 对象

isBorderOpaque

1

public boolean <b>isBorderOpaque</b>()

返回边框是否透明。

指定者:
接口 Border 中的 isBorderOpaque
覆盖:
AbstractBorder 中的 isBorderOpaque
返回:
false

getTitle

1

public String <b>getTitle</b>()

返回带标题边框的标题。


getBorder

1

public Border <b>getBorder</b>()

返回带标题边框的边框。


getTitlePosition

1

public int <b>getTitlePosition</b>()

返回带标题边框的标题位置。


getTitleJustification

1

public int <b>getTitleJustification</b>()

返回带标题边框的标题对齐方式。


getTitleFont

1

public Font <b>getTitleFont</b>()

返回带标题边框的标题字体。


getTitleColor

1

public Color <b>getTitleColor</b>()

返回带标题边框的标题颜色。


setTitle

1

public void <b>setTitle</b>(String title)

设置带标题边框的标题。参数 title 为边框的 title(标题)


setBorder

1

public void <b>setBorder</b>(Border border)

设置带标题边框的边框。

参数:
border - 边框

setTitlePosition

1

public void <b>setTitlePosition</b>(int titlePosition)

设置带标题边框的标题位置。

参数:
titlePosition - 边框的位置

setTitleJustification

1

public void <b>setTitleJustification</b>(int titleJustification)

设置带标题边框的标题对齐方式。

参数:
titleJustification - 边框标题的对齐方式

setTitleFont

1

public void <b>setTitleFont</b>(Font titleFont)

设置带标题边框的标题字体。

参数:
titleFont - 边框标题的字体

setTitleColor

1

public void <b>setTitleColor</b>(Color titleColor)

设置带标题边框的标题颜色。

参数:
titleColor - 边框标题的颜色

getMinimumSize

1

public Dimension <b>getMinimumSize</b>(Component c)

返回此边框完全显示边框和标题所需的最小大小。

参数:
c - 将在其上绘制此边框的组件

getBaseline

1

2

3

public int <b>getBaseline</b>(Component c,

                       int width,

                       int height)

返回基线。

覆盖:
AbstractBorder 中的 getBaseline
参数:
c - 将为其请求基线的 Component
width - 为其获取基线的宽度
height - 为其获取基线的高度
返回:
基线;如果 抛出:
NullPointerException
IllegalArgumentException - 如果宽度或高度 < 0
从以下版本开始:
1.6
另请参见:
JComponent.getBaseline(int, int)

getBaselineResizeBehavior

1

public Component.BaselineResizeBehavior <b>getBaselineResizeBehavior</b>(Component c)

返回一个枚举,指示该边框的基线如何随大小的改变而发生更改。

覆盖:
AbstractBorder 中的 getBaselineResizeBehavior
参数:
c - 为其返回基线调整大小行为的 Component
返回:
一个枚举,指示调整边框大小时基线如何改变
抛出:
NullPointerException
从以下版本开始:
1.6
另请参见:
JComponent.getBaseline(int, int)

getFont

1

protected Font <b>getFont</b>(Component c)


JavaTM 2 Platform
Standard Ed. 6

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

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

上一篇:SoftBevelBorder下一篇:package-frame