|
JavaTM 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 Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。