|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JToolBar
public class JToolBar
JToolBar 提供了一個用來顯示常用的 Action 或控制元件的元件。有關使用工具欄的範例和資訊,請參閱 The Java Tutorial 中的 How to Use Tool Bars 一節。
對於大多數的外觀,使用者可以將工具欄拖到單獨的視窗中(除非 floatable 屬性被設置為 false)。為了正確執行拖動,建議將 JToolBar 實例添加到容器的四“邊”中的一邊(其中容器的佈局管理器為 BorderLayout),並且不在其他四“邊”中添加任何子級。
警告:Swing 不是執行緒安全的。有關更多資訊,請參閱 Swing's Threading Policy。
警告:此類別的已序列化物件與以後的 Swing 版本不相容。當前序列化支持適用於短期存儲,或適用於在運行相同 Swing 版本的應用程序之間進行 RMI(Remote Method Invocation,遠端方法調用)。從 1.4 版本開始,已在 java.beans 套件中添加了支持所有 JavaBeansTM 長期存儲的功能。請參見 XMLEncoder。
Action| 巢狀類別摘要 | |
|---|---|
protected class |
JToolBar.AccessibleJToolBar
此類別實作對 JToolBar 類別的可存取性支持。 |
static class |
JToolBar.Separator
一個特定於工具欄的分隔符。 |
| 從類別 javax.swing.JComponent 繼承的巢狀類別/介面 |
|---|
JComponent.AccessibleJComponent |
| 從類別 java.awt.Container 繼承的巢狀類別/介面 |
|---|
Container.AccessibleAWTContainer |
| 從類別 java.awt.Component 繼承的巢狀類別/介面 |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| 欄位摘要 |
|---|
| 從類別 javax.swing.JComponent 繼承的欄位 |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| 從類別 java.awt.Component 繼承的欄位 |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| 從介面 javax.swing.SwingConstants 繼承的欄位 |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| 從介面 java.awt.image.ImageObserver 繼承的欄位 |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| 建構子摘要 | |
|---|---|
JToolBar()
創建新的工具欄;預設的方向為 HORIZONTAL。 |
|
JToolBar(int orientation)
創建具有指定 orientation 的新工具欄。 |
|
JToolBar(String name)
創建一個具有指定 name 的新工具欄。 |
|
JToolBar(String name,
int orientation)
創建一個具有指定 name 和 orientation 的新工具欄。 |
|
| 方法摘要 | |
|---|---|
JButton |
add(Action a)
添加一個指派動作的新的 JButton。 |
protected void |
addImpl(Component comp,
Object constraints,
int index)
在添加 JButton 時,它最初被設置為 disabled。 |
void |
addSeparator()
將預設大小的分隔符添加到工具欄的末尾。 |
void |
addSeparator(Dimension size)
將指定大小的分隔符添加到工具欄的末尾。 |
protected PropertyChangeListener |
createActionChangeListener(JButton b)
返回正確配置的 PropertyChangeListener,它根據 Action 的更改對控制元件進行更新,如果需要使用預設的屬性更改偵聽器,則為 null。 |
protected JButton |
createActionComponent(Action a)
將為 Action 創建 JButton 的處理器方法添加到 JToolBar 中。 |
AccessibleContext |
getAccessibleContext()
獲取與此 JToolBar 關聯的 AccessibleContext。 |
Component |
getComponentAtIndex(int i)
返回指定索引位置的元件。 |
int |
getComponentIndex(Component c)
返回指定元件的索引。 |
Insets |
getMargin()
返回工具欄邊框和它的按鈕之間的空白。 |
int |
getOrientation()
返回工具欄的當前方向。 |
ToolBarUI |
getUI()
返回工具欄的當前 UI。 |
String |
getUIClassID()
返回呈現此元件的 L&F 類別的名稱。 |
boolean |
isBorderPainted()
獲取 borderPainted 屬性。 |
boolean |
isFloatable()
獲取 floatable 屬性。 |
boolean |
isRollover()
返回 rollover 狀態。 |
protected void |
paintBorder(Graphics g)
如果 borderPainted 屬性為 true,則繪製工具欄邊框。 |
protected String |
paramString()
返回此 JToolBar 的字元串表示形式。 |
void |
setBorderPainted(boolean b)
設置 borderPainted 屬性,如果需要繪製邊框,則此屬性為 true。 |
void |
setFloatable(boolean b)
設置 floatable 屬性,如果要移動工具欄,此屬性必須設置為 true。 |
void |
setLayout(LayoutManager mgr)
設置此容器的佈局管理器。 |
void |
setMargin(Insets m)
設置工具欄邊框和它的按鈕之間的空白。 |
void |
setOrientation(int o)
設置工具欄的方向。 |
void |
setRollover(boolean rollover)
設置此工具欄的 rollover 狀態。 |
void |
setUI(ToolBarUI ui)
設置呈現此元件的 L&F 物件。 |
void |
updateUI()
UIFactory 發出的關於 L&F 已更改的通知。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 建構子詳細資訊 |
|---|
public JToolBar()
HORIZONTAL。
public JToolBar(int orientation)
orientation 的新工具欄。orientation 不是 HORIZONTAL 就是 VERTICAL。
orientation - 預期的方向public JToolBar(String name)
name 的新工具欄。名稱用作浮動式 (undocked) 工具欄的標題。預設的方向為 HORIZONTAL。
name - 工具欄的名稱
public JToolBar(String name,
int orientation)
name 和 orientation 的新工具欄。所有其他建構子均調用此建構子。如果 orientation 是一個無效值,則將拋出異常。
name - 工具欄的名稱orientation - 初始方向,它不是 HORIZONTAL 就是 VERTICAL
IllegalArgumentException - 如果方向既不是 HORIZONTAL 也不是 VERTICAL| 方法詳細資訊 |
|---|
public ToolBarUI getUI()
setUI(javax.swing.plaf.ToolBarUI)public void setUI(ToolBarUI ui)
ui - ToolBarUI L&F 物件UIDefaults.getUI(javax.swing.JComponent)public void updateUI()
UIFactory 發出的關於 L&F 已更改的通知。調用該方法,從而用 UIFactory 的最新版本來替換 UI。
JComponent 中的 updateUIJComponent.updateUI()public String getUIClassID()
JComponent 中的 getUIClassIDJComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)public int getComponentIndex(Component c)
c - 要尋找的 Component
public Component getComponentAtIndex(int i)
i - 元件的位置,從 0 開始
Component,如果索引無效則返回 nullpublic void setMargin(Insets m)
null 將導致工具欄使用預設的空白。工具欄的預設 Border 物件使用此值來創建正確的空白。不過,如果在工具欄上設置了非預設邊框,則由 Border 物件負責創建適當的空白(否則此屬性將被忽略)。
m - Insets 物件,它定義了邊框和按鈕之間的空間Insetspublic Insets getMargin()
Insets 物件Insetspublic boolean isBorderPainted()
borderPainted 屬性。
borderPainted 屬性的值setBorderPainted(boolean)public void setBorderPainted(boolean b)
borderPainted 屬性,如果需要繪製邊框,則此屬性為 true。此屬性的預設值為 true。某些外觀可能不繪製邊框,它們將忽略此屬性。
b - 如果為 true,則繪製邊框isBorderPainted()protected void paintBorder(Graphics g)
borderPainted 屬性為 true,則繪製工具欄邊框。
JComponent 中的 paintBorderg - Graphics 上下文,繪製在此上下文中完成JComponent.paint(java.awt.Graphics),
JComponent.setBorder(javax.swing.border.Border)public boolean isFloatable()
floatable 屬性。
floatable 屬性的值setFloatable(boolean)public void setFloatable(boolean b)
floatable 屬性,如果要移動工具欄,此屬性必須設置為 true。通常,可以將浮動工具欄拖動到同一個容器中的不同位置,或者拖動到自己的視窗中。此屬性的預設值為 true。某些外觀可能不實作浮動工具欄,它們將忽略此屬性。
b - 如果為 true,則工具欄可以移動;如果為 false,則工具欄不能移動isFloatable()public int getOrientation()
HORIZONTAL 就是 VERTICAL。
HORIZONTAL 就是 VERTICALsetOrientation(int)public void setOrientation(int o)
HORIZONTAL 就是 VERTICAL。如果 orientation 是一個無效值,則將拋出異常。
o - 新的方向,不是 HORIZONTAL 就是 VERTICAL
IllegalArgumentException - 如果方向既不是 HORIZONTAL 也不是 VERTICALgetOrientation()public void setRollover(boolean rollover)
外觀的實作可以選擇忽略此屬性。
rollover - 如果翻轉工具欄按鈕,則為 true;否則為 falsepublic boolean isRollover()
setRollover(boolean)public void addSeparator()
public void addSeparator(Dimension size)
size - 分隔符的 Dimensionpublic JButton add(Action a)
JButton。
a - 要作為一個新的選單項添加的 Action 物件
protected JButton createActionComponent(Action a)
Action 創建 JButton 的處理器方法添加到 JToolBar 中。如果傳遞了一個 null 操作,則預設名稱為空。
a - 要添加的按鈕的 Action
Actionprotected PropertyChangeListener createActionChangeListener(JButton b)
PropertyChangeListener,它根據 Action 的更改對控制元件進行更新,如果需要使用預設的屬性更改偵聽器,則為 null。
protected void addImpl(Component comp,
Object constraints,
int index)
JButton 時,它最初被設置為 disabled。
Container 中的 addImplcomp - 要增強的元件constraints - 元件上強制要求的約束index - 元件的索引Container.add(Component),
Container.add(Component, int),
Container.add(Component, java.lang.Object),
LayoutManager,
LayoutManager2protected String paramString()
JToolBar 的字元串表示形式。此方法僅在進行除錯的時候使用,對於各個實作,所返回字元串的內容和格式可能有所不同。返回的字元串可以為空,但不可以為 null。
JComponent 中的 paramStringJToolBar 的字元串表示形式。public void setLayout(LayoutManager mgr)
Container 複製的描述
Container 中的 setLayoutmgr - 指定的佈局管理器Container.doLayout(),
Container.getLayout()public AccessibleContext getAccessibleContext()
Accessible 中的 getAccessibleContextJComponent 中的 getAccessibleContext
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。