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.