|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.LayoutStyle
public abstract class LayoutStyle
LayoutStyle 提供有关如何确定组件位置的信息。此类主要用于可视化工具和布局管理器。大多数开发人员不需要使用此类。
通常不设置或创建 LayoutStyle。而是使用静态方法 getInstance 获取当前实例。
| 嵌套类摘要 | |
|---|---|
static class |
LayoutStyle.ComponentPlacement
ComponentPlacement 是两个组件相对于彼此的可能放置方式的枚举。 |
| 构造方法摘要 | |
|---|---|
LayoutStyle()
创建一个新的 LayoutStyle。 |
|
| 方法摘要 | |
|---|---|
abstract int |
getContainerGap(JComponent component,
int position,
Container parent)
返回组件与其父容器的指定边缘之间放置的空格数量。 |
static LayoutStyle |
getInstance()
返回 LayoutStyle 的共享实例。 |
abstract int |
getPreferredGap(JComponent component1,
JComponent component2,
LayoutStyle.ComponentPlacement type,
int position,
Container parent)
返回两个组件之间使用的空格的数量。 |
static void |
setInstance(LayoutStyle style)
设置 LayoutStyle 的共享实例。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public LayoutStyle()
LayoutStyle。通常不创建 LayoutStyle。而是使用 getInstance 方法获取当前 LayoutStyle。
| 方法详细信息 |
|---|
public static void setInstance(LayoutStyle style)
LayoutStyle 的共享实例。指定 null 将导致使用当前 LookAndFeel 的 LayoutStyle。
style - LayoutStyle,或 nullgetInstance()public static LayoutStyle getInstance()
LayoutStyle 的共享实例。如果没有在 setInstance 中指定实例,则此方法将返回当前 LookAndFeel 的 LayoutStyle。
LayoutStyle 的共享实例LookAndFeel.getLayoutStyle()
public abstract int getPreferredGap(JComponent component1,
JComponent component2,
LayoutStyle.ComponentPlacement type,
int position,
Container parent)
component1 放置 component2 的距离。例如,当 component2 被放置在 component1 的正上方时,以下代码返回 component2 和 component1 之间放置的空格数:
int gap = getPreferredGap(component1, component2, ComponentPlacement.RELATED, SwingConstants.NORTH, parent);
type 参数指示两个组件之间的关系。如果这两个组件将被包含在同一个父容器中并显示相似的逻辑相关项,则使用 RELATED。如果这两个组件将被包含在同一个父容器中但显示逻辑不相关项,则使用 UNRELATED。某些外观不区分 RELATED 和 UNRELATED 类型。
返回值不考虑 component2 或 component1 的当前大小和位置。返回值可能考虑组件的各种属性。例如,空格可能随字体大小或组件首选大小的不同而不同。
component1 - JComponent,component2 将相对于该 JComponent 被放置component2 - 将被放置的 JComponentposition - component2 将相对于 component1 进行放置的位置;SwingConstants.NORTH、SwingConstants.SOUTH、SwingConstants.EAST 或 SwingConstants.WEST 之一type - 这两个组件将如何放置parent - component2 的父容器;它可能不同于实际的父容器,可能为 null
NullPointerException - 如果 component1、component2 或 type 为 null
IllegalArgumentException - 如果 position 不是 SwingConstants.NORTH、SwingConstants.SOUTH、SwingConstants.EAST 或 SwingConstants.WEST 之一LookAndFeel.getLayoutStyle()
public abstract int getContainerGap(JComponent component,
int position,
Container parent)
component - 要放置的 JComponentposition - component 将相对于其父容器被放置的位置;SwingConstants.NORTH、SwingConstants.SOUTH、SwingConstants.EAST 或 SwingConstants.WEST 之一parent - component 的父容器;它可能不同于实际的父容器,可能为 null
IllegalArgumentException - 如果 position 不是 SwingConstants.NORTH、SwingConstants.SOUTH、SwingConstants.EAST 或 SwingConstants.WEST 之一
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。