|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.metamatrix.toolbox.ui.widget.IntegerSpinner
public class IntegerSpinner
The IntegerSpinner
is a panel consisting of a
JTextField
and two buttons. The textfield allows only integer
characters to be entered. It defaults to non-editable but can be changed
to editable. The two buttons are the "up" arrow and the "down" arrow.
The "up" arrow increments the value in the textfield and the "down" arrow
decrements the value. An increment value passed in during constructions dictates how
much is incremented or decremented.
For an editable textfield, if the value entered is greater than the maximum allowed value, the value will be set to the maximum. And if the value is less than the minimum allowed value, the value will be set to the minimum. If the spinner is wrapping and the next increment would cause the value to be greater than the maximum, the value is set to the minimum. If wrapping is off, the value would be set to the maximum. If wrapping is on and the increment would cause the value to be less than the minimum, the value is set to the maximum. If wrapping is off, the value would be set to the minimum. IntegerSpinner allows blanks to be set into the spinner
Nested Class Summary | |
---|---|
class |
IntegerSpinner.SpinnerKeyListener
|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IgnoreButton |
btnDown
|
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IgnoreButton |
btnUp
|
protected javax.swing.text.Document |
doc
The document used in the textfield. |
protected boolean |
docUpdateInProgress
Indicates if a document update is in progress. |
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IntegerSpinnerMouseListener |
downMouseListener
|
protected int |
increment
The amount of each increment or decrement. |
protected int |
max
The maximum allowed value. |
protected int |
min
The minimum allowed value. |
protected int |
minWidth
|
protected boolean |
pad
Indicates if leading zeroes will be displayed. |
protected javax.swing.JPanel |
pnlButtons
|
protected TextFieldWidget |
txf
|
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IntegerSpinnerMouseListener |
upMouseListener
|
protected int |
value
The current value. |
protected int |
width
The length of a string representation of the maximum value. |
protected boolean |
wrap
Indicates if the spinner should wrap from max to min (and vice versa) values. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
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 |
Constructor Summary | |
---|---|
IntegerSpinner(int theMin,
int theMax,
int theIncrement)
Constructs an IntegerSpinner using the given parameters and sets the initial value to min . |
|
IntegerSpinner(int theMin,
int theMax,
int theIncrement,
int theInitialValue,
boolean theWrapFlag)
Constructs an IntegerSpinner using the given parameters. |
Method Summary | |
---|---|
void |
addChangeListener(javax.swing.event.ChangeListener theListener)
|
void |
addFocusListener(java.awt.event.FocusListener theListener)
|
void |
changedUpdate(javax.swing.event.DocumentEvent theEvent)
Required by the DocumentListener interface. |
boolean |
decrement()
|
void |
focusGained(java.awt.event.FocusEvent theEvent)
Needed by the FocusListener interface. |
void |
focusLost(java.awt.event.FocusEvent theEvent)
Processes the given event by updating the value and the textfield of editable spinners. |
java.lang.String |
format()
Gets a formatted string representation if padding is set. |
int |
getMaxValue()
Gets the maximum value. |
int |
getMaxWidth()
|
int |
getMinValue()
Gets the minimum value. |
java.awt.Dimension |
getPreferredSize()
Gets the preferred size of the spinner. |
java.lang.String |
getTextValue()
|
java.lang.String |
getToolTipText()
|
int |
getValue()
Gets the current value. |
boolean |
increment()
Increments the current value by the increment value this spinner was constructed with. |
void |
insertUpdate(javax.swing.event.DocumentEvent theEvent)
Required by the DocumentListener interface. |
boolean |
isEditable()
|
void |
keyListenerKeyPressed(java.awt.event.KeyEvent theEvent)
Processes key events where the key pressed is either the up or down arrows. |
static void |
main(java.lang.String[] theArgs)
|
java.lang.String |
paramString()
|
void |
removeChangeListener(javax.swing.event.ChangeListener theListener)
|
void |
removeFocusListener(java.awt.event.FocusListener theListener)
|
void |
removeUpdate(javax.swing.event.DocumentEvent theEvent)
Required by the DocumentListener interface. |
void |
requestFocus()
Requests focus to the spinner's textfield. |
void |
setEditable(boolean theEditableFlag)
Modifies the editable state of the spinner's textfield. |
void |
setEnabled(boolean theEnableFlag)
Sets the enable state. |
void |
setMaxValue(int theNewMax)
Sets the maximum spinner value to the given value. |
void |
setMinValue(int newMin)
Sets the minimum spinner value to the given value. |
void |
setPad(boolean pad)
Sets the enable state. |
void |
setPreferredSize(java.awt.Dimension preferredSize)
Set the preferred size of the spinner. |
void |
setReadonly(boolean value)
|
boolean |
setValue(int newValue)
Sets the current value. |
java.lang.String |
toString()
Gets a formatted string representation. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, 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, hide, 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, 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, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected javax.swing.text.Document doc
protected boolean docUpdateInProgress
protected int max
protected int min
protected int increment
protected boolean pad
protected int value
protected int width
protected boolean wrap
protected int minWidth
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IntegerSpinnerMouseListener downMouseListener
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IntegerSpinnerMouseListener upMouseListener
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IgnoreButton btnDown
protected com.metamatrix.toolbox.ui.widget.IntegerSpinner.IgnoreButton btnUp
protected javax.swing.JPanel pnlButtons
protected TextFieldWidget txf
Constructor Detail |
---|
public IntegerSpinner(int theMin, int theMax, int theIncrement)
IntegerSpinner
using the given parameters and sets the initial value to min
.
theMin
- the minimum value allowedtheMax
- the maximum value allowedtheIncrement
- the amount of incrementpublic IntegerSpinner(int theMin, int theMax, int theIncrement, int theInitialValue, boolean theWrapFlag)
IntegerSpinner
using the given parameters.
theMin
- the minimum value allowedtheMax
- the maximum value allowedtheIncrement
- the amount of incrementtheInitialValue
- the initial valuetheWrapFlag
- indicates if wrapping is usedMethod Detail |
---|
public void addChangeListener(javax.swing.event.ChangeListener theListener)
public void addFocusListener(java.awt.event.FocusListener theListener)
addFocusListener
in class java.awt.Component
public void changedUpdate(javax.swing.event.DocumentEvent theEvent)
DocumentListener
interface.
changedUpdate
in interface javax.swing.event.DocumentListener
theEvent
- the event being processedDocumentListener
public boolean decrement()
public int getMaxWidth()
public boolean increment()
public void insertUpdate(javax.swing.event.DocumentEvent theEvent)
DocumentListener
interface.
insertUpdate
in interface javax.swing.event.DocumentListener
theEvent
- the event being processedDocumentListener
public boolean isEditable()
public void focusGained(java.awt.event.FocusEvent theEvent)
FocusListener
interface.
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent theEvent)
focusLost
in interface java.awt.event.FocusListener
theEvent
- the event being processedpublic java.lang.String format()
toString
representation is returned.
public int getMaxValue()
public int getMinValue()
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public java.lang.String getTextValue()
public java.lang.String getToolTipText()
getToolTipText
in class javax.swing.JComponent
public int getValue()
public void keyListenerKeyPressed(java.awt.event.KeyEvent theEvent)
theEvent
- the event being processedpublic void removeChangeListener(javax.swing.event.ChangeListener theListener)
public void removeFocusListener(java.awt.event.FocusListener theListener)
removeFocusListener
in class java.awt.Component
public void removeUpdate(javax.swing.event.DocumentEvent theEvent)
DocumentListener
interface.
removeUpdate
in interface javax.swing.event.DocumentListener
theEvent
- the event being processedDocumentListener
public void requestFocus()
requestFocus
in class javax.swing.JComponent
public java.lang.String paramString()
paramString
in class javax.swing.JPanel
public void setEditable(boolean theEditableFlag)
theEditableFlag
- sets the editable state of the textfieldpublic void setEnabled(boolean theEnableFlag)
setEnabled
in class javax.swing.JComponent
theEnableFlag
- indicates if this spinner should be enabledpublic void setMaxValue(int theNewMax)
theNewMax
- the proposed value for the maximum valuepublic void setMinValue(int newMin)
newMin
- the proposed value for the minimum valuepublic void setPad(boolean pad)
pad
- indicates if leading zeros are displayedpublic void setPreferredSize(java.awt.Dimension preferredSize)
setPreferredSize
in class javax.swing.JComponent
preferredSize
- the preferred sizepublic void setReadonly(boolean value)
public boolean setValue(int newValue)
value
- the proposed new current value
true
if the value was changed; false
otherwise.public java.lang.String toString()
toString
in class java.awt.Component
the
- string representationformat()
public static void main(java.lang.String[] theArgs)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |