javax.swing

Class JSpinner.DefaultEditor

public static class JSpinner.DefaultEditor extends JPanel implements ChangeListener, PropertyChangeListener, LayoutManager

The base class for the editor used by the {@link JSpinner} component. The editor is in fact a panel containing a {@link JFormattedTextField} component.
Constructor Summary
DefaultEditor(JSpinner spinner)
Creates a new DefaultEditor object.
Method Summary
voidaddLayoutComponent(String name, Component child)
This method does nothing.
voidcommitEdit()
DOCUMENT ME!
voiddismiss(JSpinner spinner)
Removes the editor from the {@link ChangeListener} list maintained by the specified spinner.
JSpinnergetSpinner()
Returns the JSpinner component that the editor is assigned to.
JFormattedTextFieldgetTextField()
Returns the text field used to display and edit the current value in the spinner.
voidlayoutContainer(Container parent)
Sets the bounds for the child components in this container.
DimensionminimumLayoutSize(Container parent)
Calculates the minimum size for this component.
DimensionpreferredLayoutSize(Container parent)
Calculates the preferred size for this component.
voidpropertyChange(PropertyChangeEvent event)
Receives notification of property changes.
voidremoveLayoutComponent(Component child)
This method does nothing.
voidstateChanged(ChangeEvent event)
Receives notification of changes in the state of the {@link JSpinner} that the editor belongs to - the content of the text field is updated accordingly.

Constructor Detail

DefaultEditor

public DefaultEditor(JSpinner spinner)
Creates a new DefaultEditor object. The editor is registered with the spinner as a {@link ChangeListener} here.

Parameters: spinner the JSpinner associated with this editor

Method Detail

addLayoutComponent

public void addLayoutComponent(String name, Component child)
This method does nothing. It is required by the {@link LayoutManager} interface, but since this component has a single child, there is no need to use this method.

Parameters: name the name. child the child component to add.

commitEdit

public void commitEdit()
DOCUMENT ME!

dismiss

public void dismiss(JSpinner spinner)
Removes the editor from the {@link ChangeListener} list maintained by the specified spinner.

Parameters: spinner the spinner (null not permitted).

getSpinner

public JSpinner getSpinner()
Returns the JSpinner component that the editor is assigned to.

Returns: The spinner that the editor is assigned to.

getTextField

public JFormattedTextField getTextField()
Returns the text field used to display and edit the current value in the spinner.

Returns: The text field.

layoutContainer

public void layoutContainer(Container parent)
Sets the bounds for the child components in this container. In this case, the text field is the only component to be laid out.

Parameters: parent the parent container.

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Calculates the minimum size for this component. In this case, the text field is the only subcomponent, so the return value is the minimum size of the text field plus the insets of this component.

Parameters: parent the parent container.

Returns: The minimum size.

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Calculates the preferred size for this component. In this case, the text field is the only subcomponent, so the return value is the preferred size of the text field plus the insets of this component.

Parameters: parent the parent container.

Returns: The preferred size.

propertyChange

public void propertyChange(PropertyChangeEvent event)
Receives notification of property changes. If the text field's 'value' property changes, the spinner's model is updated accordingly.

Parameters: event the event.

removeLayoutComponent

public void removeLayoutComponent(Component child)
This method does nothing. It is required by the {@link LayoutManager} interface, but since this component has a single child, there is no need to use this method.

Parameters: child the child component to remove.

stateChanged

public void stateChanged(ChangeEvent event)
Receives notification of changes in the state of the {@link JSpinner} that the editor belongs to - the content of the text field is updated accordingly.

Parameters: event the change event.