- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.SpinnerUI
-
- javax.swing.plaf.basic.BasicSpinnerUI
-
- javax.swing.plaf.synth.SynthSpinnerUI
-
- All Implemented Interfaces:
-
PropertyChangeListener,EventListener,SynthConstants,SynthUI
public class SynthSpinnerUI extends BasicSpinnerUI implements PropertyChangeListener, SynthUI
为JSpinner提供Synth L&F UI代表。- 从以下版本开始:
- 1.7
-
-
Field Summary
-
Fields inherited from class javax.swing.plaf.basic.BasicSpinnerUI
spinner
-
Fields inherited from interface javax.swing.plaf.synth.SynthConstants
DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED
-
-
构造方法摘要
构造方法 Constructor 描述 SynthSpinnerUI()
-
方法摘要
所有方法 静态方法 接口方法 具体的方法 Modifier and Type 方法 描述 protected JComponentcreateEditor()该方法由installUI调用以获取JSpinner的编辑器组件。protected LayoutManagercreateLayout()创建一个LayoutManager管理的editor,nextButton,并previousButton的JSpinner的儿童。protected ComponentcreateNextButton()创建增量按钮,即用spinner.getNextValue返回的对象替换微调spinner.getNextValue值的spinner.getNextValue。protected ComponentcreatePreviousButton()创建一个减量按钮,即使用spinner.getPreviousValue返回的对象替换微调spinner.getPreviousValue值的spinner.getPreviousValue。static ComponentUIcreateUI(JComponent c)返回SynthSpinnerUI的新实例。SynthContextgetContext(JComponent c)返回指定组件的上下文。protected voidinstallDefaults()初始化JSpinnerborder,foreground和background基于从默认值表中对应的“微调。*”的属性,属性。protected voidinstallListeners()使用共享对象初始化PropertyChangeListener,该对象将感兴趣的PropertyChangeEvents委托给受保护的方法。voidpaint(Graphics g, JComponent c)根据外观和外观绘制指定的组件。protected voidpaint(SynthContext context, Graphics g)绘制指定的组件。voidpaintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)画边框voidpropertyChange(PropertyChangeEvent e)当绑定属性更改时,此方法将被调用。protected voidreplaceEditor(JComponent oldEditor, JComponent newEditor)由PropertyChangeListener调用时,编辑器的属性变化为JSpinner。protected voiduninstallDefaults()将JSpinner's布局管理器设置为null。protected voiduninstallListeners()删除由PropertyChangeListener添加的PropertyChangeListener。voidupdate(Graphics g, JComponent c)通知此UI代理重新绘制指定的组件。-
Methods inherited from class javax.swing.plaf.basic.BasicSpinnerUI
createPropertyChangeListener, getBaseline, getBaselineResizeBehavior, installKeyboardActions, installNextButtonListeners, installPreviousButtonListeners, installUI, uninstallUI
-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize
-
-
-
-
方法详细信息
-
createUI
public static ComponentUI createUI(JComponent c)
返回SynthSpinnerUI的新实例。- 参数
-
c- JSpinner(未使用) - 结果
- 一个新的SynthSpinnerUI对象
- 另请参见:
-
ComponentUI.createUI(javax.swing.JComponent)
-
installListeners
protected void installListeners()
使用共享对象初始化PropertyChangeListener,该对象将感兴趣的PropertyChangeEvents委托给受保护的方法。此方法由
installUI。
-
uninstallListeners
protected void uninstallListeners()
删除由PropertyChangeListener添加的PropertyChangeListener。此方法由
uninstallUI。
-
installDefaults
protected void installDefaults()
初始化JSpinnerborder,foreground和background基于从默认值表中对应的“微调。*”的属性,属性。JSpinners布局设置为createLayout返回的值。 此方法由installUI。
-
uninstallDefaults
protected void uninstallDefaults()
将JSpinner's布局管理器设置为null。 此方法由uninstallUI。
-
createLayout
protected LayoutManager createLayout()
创建一个LayoutManager管理的editor,nextButton,并previousButton的JSpinner的儿童。 这三个孩子必须添加一个约束来标识其角色:“编辑”,“下一步”和“上一个”。 默认布局管理器可以处理这些孩子中没有任何一个。- 重写:
-
createLayout在BasicSpinnerUI - 结果
- 用于编辑器的LayoutManager,下一个按钮和上一个按钮。
- 另请参见:
-
BasicSpinnerUI.createNextButton(),BasicSpinnerUI.createPreviousButton(),BasicSpinnerUI.createEditor()
-
createPreviousButton
protected Component createPreviousButton()
创建一个减量按钮,即用spinner.getPreviousValue返回的对象替换微调spinner.getPreviousValue值的spinner.getPreviousValue。 默认情况下,previousButton是JButton。 如果不需要减量按钮,则此方法应返回null。- 重写:
-
createPreviousButton在BasicSpinnerUI - 结果
-
将使用序列中的先前值替换微调器值的组件,或
null - 另请参见:
-
BasicSpinnerUI.installUI(javax.swing.JComponent),BasicSpinnerUI.createNextButton(),BasicSpinnerUI.installPreviousButtonListeners(java.awt.Component)
-
createNextButton
protected Component createNextButton()
创建一个增量按钮,即用spinner.getNextValue返回的对象替换微调spinner.getNextValue值的spinner.getNextValue。 默认情况下,nextButton是JButton。 如果不需要增量按钮,则此方法应返回null。- 重写:
-
createNextButton在BasicSpinnerUI - 结果
-
将使用序列中的下一个值替换微调器值的组件,或
null - 另请参见:
-
BasicSpinnerUI.installUI(javax.swing.JComponent),BasicSpinnerUI.createPreviousButton(),BasicSpinnerUI.installNextButtonListeners(java.awt.Component)
-
createEditor
protected JComponent createEditor()
该方法由installUI调用,以获得JSpinner的编辑器组件。 默认情况下,它只返回JSpinner.getEditor()。 子类可以重写createEditor返回包含微调的编辑器或空,如果他们要处理添加编辑器的组件JSpinner在installUI覆盖。通常,这个方法将被覆盖,使编辑器包含带有自定义边框的容器,因为不能假定编辑器边框可以直接设置。
当使用
JSpinner.setEditor更改旋转编辑器时,将调用replaceEditor方法。 如果您已经覆盖了此方法,那么您也可能需要覆盖replaceEditor。- 重写:
-
createEditor在BasicSpinnerUI - 结果
- JSpinners编辑器JComponent,spinner.getEditor()默认情况下
- 另请参见:
-
BasicSpinnerUI.installUI(javax.swing.JComponent),replaceEditor(javax.swing.JComponent, javax.swing.JComponent),JSpinner.getEditor()
-
replaceEditor
protected void replaceEditor(JComponent oldEditor, JComponent newEditor)
由被叫PropertyChangeListener当JSpinner编辑属性更改。 删除旧编辑器并添加新编辑器是有责任的。 默认情况下这个操作只是:spinner.remove(oldEditor); spinner.add(newEditor, "Editor");replaceEditor的实施应与createEditor方法协调。- 重写:
-
replaceEditor在BasicSpinnerUI - 参数
-
oldEditor- 一个旧的编辑器 -
newEditor- 一个新的编辑实例 - 另请参见:
-
createEditor(),BasicSpinnerUI.createPropertyChangeListener()
-
getContext
public SynthContext getContext(JComponent c)
返回指定组件的上下文。- Specified by:
-
getContext在接口SynthUI - 参数
-
c- 组件请求SynthContext。 - 结果
- SynthContext描述组件。
-
update
public void update(Graphics g, JComponent c)
通知此UI代理重新绘制指定的组件。 该方法绘制组件背景,然后调用paint(SynthContext,Graphics)方法。通常,此方法不需要被子类覆盖。 所有Look和Feel渲染代码都应该在
paint。- 重写:
-
update在ComponentUI - 参数
-
g- 用于绘画的Graphics对象 -
c- 正在涂漆的组件 - 另请参见:
-
paint(SynthContext,Graphics)
-
paint
public void paint(Graphics g, JComponent c)
根据外观和外观绘制指定的组件。Synth Look and Feel不使用此方法。 绘画由
paint(SynthContext,Graphics)处理。- 重写:
-
paint在ComponentUI - 参数
-
g- 用于绘画的Graphics对象 -
c- 正在涂漆的组件 - 另请参见:
-
paint(SynthContext,Graphics)
-
paint
protected void paint(SynthContext context, Graphics g)
绘制指定的组件。 这个实现什么都不做。- 参数
-
context- 要绘制的组件的上下文 -
g- 用于绘画的Graphics对象 - 另请参见:
-
update(Graphics,JComponent)
-
paintBorder
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)
画边框- Specified by:
-
paintBorder在接口SynthUI - 参数
-
context- 组件上下文 -
g-Graphics上画 -
x- X坐标 -
y- Y坐标 -
w- 边框的宽度 -
h- 边框的高度
-
propertyChange
public void propertyChange(PropertyChangeEvent e)
当绑定属性更改时,此方法将被调用。- Specified by:
-
propertyChange在接口PropertyChangeListener - 参数
-
e- A PropertyChangeEvent object describing the event source and the property that has changed.
-
-