|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.plaf.ComponentUI
javax.swing.plaf.SpinnerUI
javax.swing.plaf.basic.BasicSpinnerUI
public class BasicSpinnerUI
默认 Spinner UI 委托。
| 字段摘要 | |
|---|---|
protected JSpinner |
spinner
作为 UI 委托的 spinner。 |
| 构造方法摘要 | |
|---|---|
BasicSpinnerUI()
|
|
| 方法摘要 | |
|---|---|
protected JComponent |
createEditor()
installUI 通过调用此方法获取 JSpinner 的编辑器组件。 |
protected LayoutManager |
createLayout()
创建管理 JSpinner 的 editor、nextButton 和 previousButton 子级的 LayoutManager。 |
protected Component |
createNextButton()
创建将用 spinner.getNextValue 返回的对象取代 spinner 模型值的组件。 |
protected Component |
createPreviousButton()
创建将用 spinner.getPreviousValue 返回的对象取代 spinner 模型值的组件。 |
protected PropertyChangeListener |
createPropertyChangeListener()
创建一个可以添加到 JSpinner 本身的 PropertyChangeListener。 |
static ComponentUI |
createUI(JComponent c)
返回 BasicSpinnerUI 的新实例。 |
int |
getBaseline(JComponent c,
int width,
int height)
返回基线。 |
Component.BaselineResizeBehavior |
getBaselineResizeBehavior(JComponent c)
返回一个枚举,它指示该组件的基线如何随大小的改变而发生更改。 |
protected void |
installDefaults()
初始化 JSpinner border、foreground、background 属性以及基于默认表中对应的 "Spinner.*" 属性。 |
protected void |
installKeyboardActions()
在 JSpinner 上安装键盘动作。 |
protected void |
installListeners()
用将感兴趣的 PropertyChangeEvent 委托给受保护方法的共享对象初始化 PropertyChangeListener。 |
protected void |
installNextButtonListeners(Component c)
在下一个按钮( c)上安装必要的侦听器以更新 JSpinner 来响应用户动作。 |
protected void |
installPreviousButtonListeners(Component c)
在上一个按钮( c)上安装必要的侦听器以更新 JSpinner 来响应用户动作。 |
void |
installUI(JComponent c)
调用 installDefaults、installListeners,然后添加由 createNextButton、createPreviousButton 和 createEditor 返回的组件。 |
protected void |
replaceEditor(JComponent oldEditor,
JComponent newEditor)
当 JSpinner 编辑器属性更改时,由 PropertyChangeListener 调用。 |
protected void |
uninstallDefaults()
将 JSpinner 的布局管理器设置为 null。 |
protected void |
uninstallListeners()
移除 installListeners 添加的 PropertyChangeListener。 |
void |
uninstallUI(JComponent c)
调用 uninstallDefaults、uninstallListeners,然后移除所有子 spinner。 |
| 从类 javax.swing.plaf.ComponentUI 继承的方法 |
|---|
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, paint, update |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected JSpinner spinner
installUI 方法初始化,并由 uninstallUI 重置为 null。
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)| 构造方法详细信息 |
|---|
public BasicSpinnerUI()
| 方法详细信息 |
|---|
public static ComponentUI createUI(JComponent c)
c - JSpinner(未使用)
ComponentUI.createUI(javax.swing.JComponent)public void installUI(JComponent c)
installDefaults、installListeners,然后添加由 createNextButton、createPreviousButton 和 createEditor 返回的组件。
ComponentUI 中的 installUIc - JSpinnerinstallDefaults(),
installListeners(),
createNextButton(),
createPreviousButton(),
createEditor()public void uninstallUI(JComponent c)
uninstallDefaults、uninstallListeners,然后移除所有子 spinner。
ComponentUI 中的 uninstallUIc - JSpinner(不使用)ComponentUI.installUI(javax.swing.JComponent),
JComponent.updateUI()protected void installListeners()
PropertyChangeListener。
此方法由 installUI 调用。
replaceEditor(javax.swing.JComponent, javax.swing.JComponent),
uninstallListeners()protected void uninstallListeners()
PropertyChangeListener。
此方法由 uninstallUI 调用。
installListeners()protected void installDefaults()
JSpinner border、foreground、background 属性以及基于默认表中对应的 "Spinner.*" 属性。将 JSpinner 布局设置为 createLayout 返回的值。此方法由 installUI 调用。
uninstallDefaults(),
installUI(javax.swing.JComponent),
createLayout(),
LookAndFeel.installBorder(javax.swing.JComponent, java.lang.String),
LookAndFeel.installColors(javax.swing.JComponent, java.lang.String, java.lang.String)protected void uninstallDefaults()
JSpinner 的布局管理器设置为 null。此方法由 uninstallUI 调用。
installDefaults(),
uninstallUI(javax.swing.JComponent)protected void installNextButtonListeners(Component c)
c)上安装必要的侦听器以更新 JSpinner 来响应用户动作。
c - 要在其上安装侦听器的组件
NullPointerException - 如果 c 为 null。createNextButton()protected void installPreviousButtonListeners(Component c)
c)上安装必要的侦听器以更新 JSpinner 来响应用户动作。
c - 要在其上安装侦听器的组件。
NullPointerException - 如果 c 为 null。createPreviousButton()protected LayoutManager createLayout()
editor、nextButton 和 previousButton 子级的 LayoutManager。必须用标识其职责的约束添加这三个子级:"Editor"、"Next"、和 "Previous"。默认的布局管理器可以处理缺少这些子级中任意一个的情况。
createNextButton(),
createPreviousButton(),
createEditor()protected PropertyChangeListener createPropertyChangeListener()
PropertyChangeListener。通常,此侦听器将在“编辑器”属性更改时调用 replaceEditor,因为它的 SpinnerUI 负责将编辑器添加到 JSpinner(并移除旧的)。此方法由 installListeners 调用。
installListeners()protected Component createPreviousButton()
spinner.getPreviousValue 返回的对象取代 spinner 模型值的组件。默认情况下 previousButton 为 JButton。此方法通过调用 installPreviousButtonListeners 安装必需的侦听器以更新 JSpinner 的模型来响应用户动作。如果不需要 previousButton(在子类中),则重写此方法以返回 null。
installUI(javax.swing.JComponent),
createNextButton(),
installPreviousButtonListeners(java.awt.Component)protected Component createNextButton()
spinner.getNextValue 返回的对象取代 spinner 模型值的组件。默认情况下,nextButton 即为 JButton,其 ActionListener 更新其 JSpinner 祖先模型。如果不需要 nextButton(在子类中),则重写此方法以返回 null。
installUI(javax.swing.JComponent),
createPreviousButton(),
installNextButtonListeners(java.awt.Component)protected JComponent createEditor()
JSpinner 的编辑器组件。默认情况下它仅返回 JSpinner.getEditor()。如果子类要使用重写的 installUI 将编辑器添加到 JSpinner 中,则其可以重写 createEditor 来返回包含 spinner 的编辑器的组件或 null。
通常重写此方法以利用带有自定义边框的容器包装编辑器,因为不能假定可以直接设置编辑器的边框。
利用 JSpinner.setEditor 更改 spinner 的编辑器时调用 replaceEditor 方法。如果已重写此方法,则可能还要重写 replaceEditor。
installUI(javax.swing.JComponent),
replaceEditor(javax.swing.JComponent, javax.swing.JComponent),
JSpinner.getEditor()
protected void replaceEditor(JComponent oldEditor,
JComponent newEditor)
JSpinner 编辑器属性更改时,由 PropertyChangeListener 调用。此方法负责移除旧编辑器并添加新编辑器。默认情况下,此操作为:
spinner.remove(oldEditor); spinner.add(newEditor, "Editor");
replaceEditor 的实现应该配合 createEditor 方法使用。
createEditor(),
createPropertyChangeListener()protected void installKeyboardActions()
public int getBaseline(JComponent c,
int width,
int height)
ComponentUI 中的 getBaselinec - 为其请求基线的 JComponentwidth - 为其获取基线的宽度height - 为其获取基线的高度
NullPointerException - 如果 c 为 null
IllegalArgumentException - 如果宽度或高度 < 0JComponent.getBaseline(int, int)public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
ComponentUI 中的 getBaselineResizeBehaviorc - 为其返回调整大小行为的 JComponent
NullPointerException - 如果 c 为 nullJComponent.getBaseline(int, int)
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。