public class BasicSpinnerUI extends SpinnerUI
| Modifier and Type | Field and Description |
|---|---|
protected JSpinner |
spinner
我们是一个UI委托的微调器。
|
| Constructor and Description |
|---|
BasicSpinnerUI() |
| Modifier and Type | Method and Description |
|---|---|
protected JComponent |
createEditor()
该方法由installUI调用以获取JSpinner的编辑器
JSpinner 。
|
protected LayoutManager |
createLayout()
创建一个
LayoutManager管理该
editor ,
nextButton和
previousButton的JSpinner的儿童。
|
protected Component |
createNextButton()
创建一个增量按钮,即
|
protected Component |
createPreviousButton()
创建一个减量按钮,即
|
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基于从默认值表中对应的“微调。*”的属性,属性。
|
protected void |
installKeyboardActions()
将键盘操作安装到JSpinner上。
|
protected void |
installListeners()
使用共享对象初始化
PropertyChangeListener ,该共享对象将有趣的PropertyChangeEvents委托给受保护的方法。
|
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)
PropertyChangeListener当
JSpinner编辑器属性改变时调用。
|
protected void |
uninstallDefaults()
将
JSpinner's布局管理器设置为null。
|
protected void |
uninstallListeners()
删除由
PropertyChangeListener添加的PropertyChangeListener。
|
void |
uninstallUI(JComponent c)
电话
uninstallDefaults ,
uninstallListeners ,然后删除所有的纺纱孩子。
|
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, paint, updateprotected JSpinner spinner
installUI方法初始化,并由uninstallUI重置为null。
public static ComponentUI createUI(JComponent c)
c - JSpinner(未使用)
ComponentUI.createUI(javax.swing.JComponent)
public void installUI(JComponent c)
installDefaults ,
installListeners ,然后将返回的组件
createNextButton ,
createPreviousButton和
createEditor 。
installUI在
ComponentUI类
c - JSpinner
installDefaults() ,
installListeners() ,
createNextButton() ,
createPreviousButton() ,
createEditor()
public void uninstallUI(JComponent c)
uninstallDefaults ,
uninstallListeners ,然后删除所有的纺纱孩子。
uninstallUI在
ComponentUI
c - JSpinner(未使用)
ComponentUI.installUI(javax.swing.JComponent) ,
JComponent.updateUI()
protected void installListeners()
PropertyChangeListener ,该共享对象将有趣的PropertyChangeEvents委托给受保护的方法。
该方法由installUI 。
protected void uninstallListeners()
PropertyChangeListener添加的PropertyChangeListener。
此方法由uninstallUI 。
installListeners()
protected void installDefaults()
JSpinner border , foreground和background基于从默认值表中对应的“微调。*”的属性,属性。
JSpinners布局设置为createLayout返回的值。
此方法由installUI 。
protected void uninstallDefaults()
JSpinner's布局管理器设置为null。
此方法由uninstallUI 。
protected void installNextButtonListeners(Component c)
c ,以更新
JSpinner响应于用户手势。
c - 安装监听器的组件
NullPointerException - 如果
c为空。
createNextButton()
protected void installPreviousButtonListeners(Component c)
c ,以更新
JSpinner以响应用户的手势。
c - 安装监听器的组件。
NullPointerException - 如果
c为空。
createPreviousButton()
protected LayoutManager createLayout()
LayoutManager管理该editor , nextButton和previousButton的JSpinner的儿童。
这三个孩子必须添加一个约束来标识他们的角色:“编辑”,“下一步”和“上一个”。
默认布局管理器可以处理这些孩子中没有任何一个。
createNextButton() ,
createPreviousButton() ,
createEditor()
protected PropertyChangeListener createPropertyChangeListener()
PropertyChangeListener 。
通常,当“editor”属性更改时,此侦听器将调用replaceEditor,因为将编辑器添加到JSpinner(并删除旧的)将是SpinnerUI's责任。
此方法由installListeners 。
installListeners()
protected Component createPreviousButton()
spinner.getPreviousValue 。
默认情况下, previousButton是JButton 。
如果不需要减量按钮,则此方法应返回null 。
null
installUI(javax.swing.JComponent) ,
createNextButton() ,
installPreviousButtonListeners(java.awt.Component)
protected Component createNextButton()
spinner.getNextValue 。
默认情况下, nextButton是JButton 。
如果不需要增量按钮,则此方法应返回null 。
null
installUI(javax.swing.JComponent) ,
createPreviousButton() ,
installNextButtonListeners(java.awt.Component)
protected JComponent createEditor()
JSpinner 。
默认情况下,它只返回JSpinner.getEditor() 。
子类可以覆盖createEditor以返回包含微调器编辑器的组件或null,如果他们要处理将编辑器添加到JSpinner中的installUI覆盖中。
通常,这个方法将被覆盖,使编辑器包含带有自定义边框的容器,因为不能假定编辑器边框可以直接设置。
当使用JSpinner.setEditor更改旋转编辑器时,将调用replaceEditor方法。 如果您已经覆盖了此方法,那么您也可能需要覆盖replaceEditor 。
installUI(javax.swing.JComponent) ,
replaceEditor(javax.swing.JComponent, javax.swing.JComponent) ,
JSpinner.getEditor()
protected void replaceEditor(JComponent oldEditor, JComponent newEditor)
PropertyChangeListener调用时, JSpinner编辑器属性发生变化。
删除旧编辑器并添加新编辑器是有责任的。
默认情况下这个操作只是:
spinner.remove(oldEditor);
spinner.add(newEditor, "Editor");
执行replaceEditor应与createEditor方法createEditor 。
protected void installKeyboardActions()
public int getBaseline(JComponent c, int width, int height)
getBaseline在
ComponentUI类
c -
JComponent正在请求基准
width - 获取基准的宽度
height - 获得基准的高度
NullPointerException - 如果
c是
null
IllegalArgumentException - 如果宽度或高度<0
JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior在
ComponentUI
c -
JComponent以返回基准调整大小行为
NullPointerException - 如果
c是
null
JComponent.getBaseline(int, int)
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.