public static class JSpinner.DefaultEditor extends JPanel implements ChangeListener, PropertyChangeListener, LayoutManager
JFormattedTextField
。
子类可以配置JFormattedTextField
创建一个适合于他们支持的模型类型的编辑器,并且可能需要覆盖stateChanged
和propertyChanged
方法,以保持模型和文本字段同步。
这个类定义了一个dismiss
方法,它从dismiss
中删除了ChangeListener
JSpinner
,它是它的一部分。 setEditor
方法知道DefaultEditor.dismiss
,所以如果开发人员替换了一个编辑器,从JSpinner.DefaultEditor
派生出来,其ChangeListener
连接将返回到JSpinner
将被删除。 然而,之后,由开发人员管理他们的编辑器听众。 类似地,如果子类覆盖createEditor
,则由子类来处理他们的编辑器,随后被替换(使用setEditor
)。 我们预计在大多数情况下,在编辑器中安装setEditor
或由createEditor
重写创建,将不会被替换。
这个班是LayoutManager
的单身JFormattedTextField
孩子。 默认情况下,孩子只是以父母插图为中心。
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DefaultEditor(JSpinner spinner)
构造指定的编辑器组件
JSpinner 。
|
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(String name, Component child)
这
LayoutManager 方法什么都不做。
|
void |
commitEdit()
将当前编辑的值推送到
SpinnerModel 。
|
void |
dismiss(JSpinner spinner)
从指定的JSpinner
JSpinner
this 编辑器。
|
int |
getBaseline(int width, int height)
返回基线。
|
Component.BaselineResizeBehavior |
getBaselineResizeBehavior()
返回一个枚举,指示组件的基线如何随着大小的变化而改变。
|
JSpinner |
getSpinner()
返回
JSpinner 祖先此编辑器或
null 如果没有祖先是
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)
当微调框的模型状态发生变化时,将调用此方法。
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public DefaultEditor(JSpinner spinner)
JSpinner
编辑器JSpinner
。
这个DefaultEditor
是自己的布局管理器,它被添加到微调器的ChangeListener
列表中。
构造函数创建一个单独的JFormattedTextField
子项,将其初始化为微调模型的当前值,并将其添加到this
DefaultEditor
。
spinner
- 型号
this
编辑器将监控的微调器
getTextField()
,
JSpinner.addChangeListener(javax.swing.event.ChangeListener)
public void dismiss(JSpinner spinner)
JSpinner
this
编辑器。
默认情况下,此方法会从旋转器ChangeListener
列表中删除。
spinner
- 要断开此编辑器的JSpinner
;
与传递给构造函数的旋转器相同。
public JSpinner getSpinner()
JSpinner
祖先此编辑器或null
如果没有祖先是JSpinner
。
典型地,所述编辑器的父是JSpinner
然而的子类JSpinner
可重写的createEditor
方法和插入之间的一个或多个容器JSpinner
和它的编辑。
JSpinner
null
如果没有祖先是JSpinner
JSpinner.createEditor(javax.swing.SpinnerModel)
public JFormattedTextField getTextField()
JFormattedTextField
小孩。
默认情况下,文本字段是编辑器的第一个也是唯一的子节点。
JFormattedTextField
给用户访问
SpinnerDateModel's
值。
getSpinner()
,
JSpinner.getModel()
public void stateChanged(ChangeEvent e)
value
设置为纺纱模型的当前值。
stateChanged
在接口
ChangeListener
e
-
ChangeEvent
的来源是
JSpinner
,其型号已更改。
getTextField()
,
JSpinner.getValue()
public void propertyChange(PropertyChangeEvent e)
JFormattedTextField
PropertyChangeListener
。
当"value"
属性更改时,这意味着用户键入了新的数字,我们设置了旋转模型的值。
这个类忽略PropertyChangeEvents
,其来源不是JFormattedTextField
,这样子类可以安全地进行this
DefaultEditor
一个PropertyChangeListener
上的其他对象。
propertyChange
在接口
PropertyChangeListener
e
-
PropertyChangeEvent
的来源是这个类创建的
JFormattedTextField
。
getTextField()
public void addLayoutComponent(String name, Component child)
LayoutManager
方法什么都不做。
我们只管理一个孩子,并且不支持布局约束。
addLayoutComponent
在界面
LayoutManager
name
- 忽略
child
- 忽略
public void removeLayoutComponent(Component child)
LayoutManager
方法什么都不做。
没有任何每个孩子的状态。
removeLayoutComponent
中的
LayoutManager
child
- 忽略
public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize
在接口
LayoutManager
parent
- 管理布局的容器
LayoutManager.minimumLayoutSize(java.awt.Container)
public Dimension minimumLayoutSize(Container parent)
minimumLayoutSize
在接口
LayoutManager
parent
- 管理布局的容器
LayoutManager.preferredLayoutSize(java.awt.Container)
public void layoutContainer(Container parent)
layoutContainer
在接口
LayoutManager
parent
- 要布置的容器
public void commitEdit() throws ParseException
SpinnerModel
。
默认实现在commitEdit
上调用JFormattedTextField
。
ParseException
- 如果编辑的值不合法
public int getBaseline(int width, int height)
getBaseline
在
JComponent
width
- 获取基准的宽度
height
- 获取基准的高度
IllegalArgumentException
- 如果宽度或高度<0
JComponent.getBaseline(int,int)
,
JComponent.getBaselineResizeBehavior()
public Component.BaselineResizeBehavior getBaselineResizeBehavior()
getBaselineResizeBehavior
在
JComponent
NullPointerException
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.