- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- javax.swing.JSpinner.DefaultEditor
-
- All Implemented Interfaces:
-
ImageObserver
,LayoutManager
,MenuContainer
,PropertyChangeListener
,Serializable
,EventListener
,Accessible
,ChangeListener
- Enclosing class:
- JSpinner
public static class JSpinner.DefaultEditor extends JPanel implements ChangeListener, PropertyChangeListener, LayoutManager
更专业的编辑器的简单基础类,用于显示模型当前值的只读视图,并使用JFormattedTextField
。 子类可以配置JFormattedTextField
创建一个适合于他们支持的模型类型的编辑器,并且他们可能想要覆盖stateChanged
和propertyChanged
方法,从而使模型和文本字段保持同步。这个类定义一个
dismiss
方法,其去除的编辑ChangeListener
从JSpinner
,它的组成部分。setEditor
方法知道DefaultEditor.dismiss
,所以如果开发人员替换从JSpinner.DefaultEditor
派生的编辑器,其ChangeListener
连接将回到JSpinner
将被删除。 然而,之后,由开发人员管理他们的编辑器听众。 类似地,如果子类覆盖createEditor
,createEditor
子类来处理他们的编辑器,随后被替换(使用setEditor
)。 我们预计在大多数情况下,在编辑器中安装setEditor
或由createEditor
重写创建,将不会被替换。这个班是
LayoutManager
的单身JFormattedTextField
孩子。 默认情况下,孩子只是以父母插图为中心。- 从以下版本开始:
- 1.4
- 另请参见:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
-
Field Summary
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
构造方法摘要
构造方法 Constructor 描述 DefaultEditor(JSpinner spinner)
构造指定的编辑器组件JSpinner
。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 void
addLayoutComponent(String name, Component child)
这个LayoutManager
方法什么都不做。void
commitEdit()
将当前编辑的值推送到SpinnerModel
。void
dismiss(JSpinner spinner)
从指定的JSpinner
断开this
编辑器。int
getBaseline(int width, int height)
返回基线。Component.BaselineResizeBehavior
getBaselineResizeBehavior()
返回一个枚举,指示组件的基线如何随着大小的变化而改变。JSpinner
getSpinner()
如果没有一个祖先是null
则返回此编辑器的JSpinner
祖先或JSpinner
。JFormattedTextField
getTextField()
返回此编辑器的JFormattedTextField
小子。void
layoutContainer(Container parent)
调整一个(而且只)的孩子,以完全填补父母插图内的区域。Dimension
minimumLayoutSize(Container parent)
返回第一个(且仅))小孩的最小大小加上父母插入的大小。Dimension
preferredLayoutSize(Container parent)
返回首个(而且仅)子项的首选大小加上父母插入的大小。void
propertyChange(PropertyChangeEvent e)
调用JFormattedTextField
PropertyChangeListener
。void
removeLayoutComponent(Component child)
这个LayoutManager
方法什么都不做。void
stateChanged(ChangeEvent e)
当微调框的模型状态发生变化时,将调用此方法。-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
-
-
-
构造方法详细信息
-
DefaultEditor
public DefaultEditor(JSpinner spinner)
构造指定的编辑器组件JSpinner
。 这是DefaultEditor
是自己的布局管理器,它被添加到微调器的ChangeListener
列表。 构造函数创建一个单独的JFormattedTextField
子项,将其初始化为微调器模型的当前值,并将其添加到this
DefaultEditor
。- 参数
-
spinner
-this
编辑器将监控的微调器 - 另请参见:
-
getTextField()
,JSpinner.addChangeListener(javax.swing.event.ChangeListener)
-
-
方法详细信息
-
dismiss
public void dismiss(JSpinner spinner)
从指定的JSpinner
断开this
编辑器。 默认情况下,此方法将从自己的ChangeListener
列表中删除。- 参数
-
spinner
- 要断开此编辑器的JSpinner
; 与传递给构造函数的旋转器相同。
-
getSpinner
public JSpinner getSpinner()
如果没有一个祖先是null
则返回此编辑器的JSpinner
祖先或JSpinner
。 典型地,所述编辑器的父是JSpinner
然而的子类JSpinner
可重写的createEditor
方法和插入之间的一个或多个容器JSpinner
和它的编辑。- 结果
-
祖先
JSpinner
null
如果没有祖先是JSpinner
- 另请参见:
-
JSpinner.createEditor(javax.swing.SpinnerModel)
-
getTextField
public JFormattedTextField getTextField()
返回此编辑器的JFormattedTextField
子项。 默认情况下,文本字段是编辑器的第一个也是唯一的子节点。- 结果
-
JFormattedTextField
给用户访问SpinnerDateModel's
值。 - 另请参见:
-
getSpinner()
,JSpinner.getModel()
-
stateChanged
public void stateChanged(ChangeEvent e)
当微调框的模型状态发生变化时,将调用此方法。 它将文本字段的value
设置为纺纱模型的当前值。- Specified by:
-
stateChanged
在接口ChangeListener
- 参数
-
e
- 其中ChangeEvent
的来源是其型号已更改的JSpinner
。 - 另请参见:
-
getTextField()
,JSpinner.getValue()
-
propertyChange
public void propertyChange(PropertyChangeEvent e)
称为JFormattedTextField
PropertyChangeListener
。 当"value"
属性更改时,这意味着用户键入了新的数字,我们设置了旋转模型的值。这个类忽略
PropertyChangeEvents
,其来源不是JFormattedTextField
,这样子类可以安全地进行this
DefaultEditor
一个PropertyChangeListener
上的其他对象。- Specified by:
-
propertyChange
在接口PropertyChangeListener
- 参数
-
e
-PropertyChangeEvent
的来源是这个类创建的JFormattedTextField
。 - 另请参见:
-
getTextField()
-
addLayoutComponent
public void addLayoutComponent(String name, Component child)
这个LayoutManager
方法什么都不做。 我们只管理一个孩子,并且不支持布局约束。- Specified by:
-
addLayoutComponent
在接口LayoutManager
- 参数
-
name
- 忽略 -
child
- 忽略
-
removeLayoutComponent
public void removeLayoutComponent(Component child)
这个LayoutManager
方法什么都不做。 没有任何每个孩子的状态。- Specified by:
-
removeLayoutComponent
在接口LayoutManager
- 参数
-
child
- 忽略
-
preferredLayoutSize
public Dimension preferredLayoutSize(Container parent)
返回首个(而且仅)子项的首选大小加上父母插入的大小。- Specified by:
-
preferredLayoutSize
在接口LayoutManager
- 参数
-
parent
- 管理布局的容器 - 结果
- 布置指定容器的子组件的首选尺寸。
- 另请参见:
-
LayoutManager.minimumLayoutSize(java.awt.Container)
-
minimumLayoutSize
public Dimension minimumLayoutSize(Container parent)
返回第一个(且仅))小孩的最小大小加上父母插入的大小。- Specified by:
-
minimumLayoutSize
在接口LayoutManager
- 参数
-
parent
- 管理布局的容器 - 结果
- 布置指定容器的子组件所需的最小尺寸。
- 另请参见:
-
LayoutManager.preferredLayoutSize(java.awt.Container)
-
layoutContainer
public void layoutContainer(Container parent)
调整一个(而且只)的孩子,以完全填补父母插图内的区域。- Specified by:
-
layoutContainer
在接口LayoutManager
- 参数
-
parent
- 要布置的容器
-
commitEdit
public void commitEdit() throws ParseException
将当前编辑的值推送到SpinnerModel
。默认实现在
commitEdit
上调用JFormattedTextField
。- 异常
-
ParseException
- 如果编辑的值不合法
-
getBaseline
public int getBaseline(int width, int height)
返回基线。- 重写:
-
getBaseline
在JComponent
- 参数
-
width
- 获取基准的宽度 -
height
- 获取基准的高度 - 结果
- 基线或<0表示没有合理的基线
- 异常
-
IllegalArgumentException
- 如果宽度或高度<0 - 从以下版本开始:
- 1.6
- 另请参见:
-
JComponent.getBaseline(int,int)
,JComponent.getBaselineResizeBehavior()
-
getBaselineResizeBehavior
public Component.BaselineResizeBehavior getBaselineResizeBehavior()
返回一个枚举,指示组件的基线如何随着大小的变化而改变。- 重写:
-
getBaselineResizeBehavior
在JComponent
- 结果
- 一个枚举,指示基准随着组件大小的变化而改变
- 异常
-
NullPointerException
- 从以下版本开始:
- 1.6
- 另请参见:
-
JComponent.getBaseline(int, int)
-
-