public abstract class LayoutStyle extends Object
LayoutStyle提供了有关如何定位组件。这个类主要用于可视化工具和布局管理器。大多数开发人员将不需要使用这个类。
你通常不设置或创建一个LayoutStyle。而使用静态方法getInstance获取当前实例。
| Modifier and Type | Class and Description |
|---|---|
static class |
LayoutStyle.ComponentPlacement
ComponentPlacement是枚举的可能途径两部分可以放置彼此相对。
|
| Constructor and Description |
|---|
LayoutStyle()
创建一个新的
LayoutStyle。
|
| Modifier and Type | Method and Description |
|---|---|
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共享的实例。
|
public LayoutStyle()
LayoutStyle。你通常不会创建一个
LayoutStyle。而使用的方法
getInstance获取当前
LayoutStyle。
public static void setInstance(LayoutStyle style)
LayoutStyle共享的实例。在使用当前
LookAndFeel的
LayoutStyle指定
null结果。
style -
LayoutStyle,或
null
getInstance()
public static LayoutStyle getInstance()
LayoutStyle共享的实例。如果一个实例没有被指定在
setInstance,这将从目前的
LayoutStyle
LookAndFeel。
LayoutStyle共享的实例
LookAndFeel.getLayoutStyle()
public abstract int getPreferredGap(JComponent component1, JComponent component2, LayoutStyle.ComponentPlacement type, int position, Container parent)
component2相对
component1距离。例如,下面的回报金额空间的地方
component2和
component1之间时
component2垂直放置在
component1:
国际差距= getpreferredgap(1,放置,componentplacement.related,SwingConstants.NORTH家长);的
type参数表示两者之间的关系。如果两个组件将被包含在相同的父,也显示出类似的逻辑上相关的项目,使用
RELATED。如果两组件将被包含在同一母但显示逻辑无关的物品使用
UNRELATED。一些看起来和感觉可能不区分
RELATED和
UNRELATED类型。
返回值是不打算考虑当前的大小和位置component2或component1。返回值可以考虑考虑各种性能的组件。例如,空间可能会根据字体大小而有所不同,或组件的首选大小。
component1 -
JComponent
component2仍然处于相对
component2 -
JComponent放
position -位置
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 -
JComponent定位
position -位置
component是放相对于它的父;一个
SwingConstants.NORTH,
SwingConstants.SOUTH,
SwingConstants.EAST或
SwingConstants.WEST
parent -
component母;这可能与实际的家长可以
null
IllegalArgumentException -如果
position不是一
SwingConstants.NORTH,
SwingConstants.SOUTH,
SwingConstants.EAST或
SwingConstants.WEST
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.