|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。