org.springframework.richclient.swing
Class BigDecimalTextField
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
org.springframework.richclient.swing.BigDecimalTextField
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants
public class BigDecimalTextField
- extends JTextField
This class can have different "read" and "write" formats. When showing the
number the "read" format will be used. If the user enters the inputfield
(gains focus), the "write" format will be used.
A maximum of decimals/non-decimals can be specified so no more numbers can be
input than strictly defined.
A boolean can be specified to allow only positive numbers or positive and
negative numbers. Switching between positive and negative can be done by
using the +/- buttons anywhere in the inputfield.
TODO There's a third option: only negative numbers, this should be
configurable as well.
- Author:
- Jan Hoskens
- See Also:
- Serialized Form
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Constructor Summary |
BigDecimalTextField()
Default constructor. |
BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign)
|
BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign,
Class numberClass)
|
BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign,
Class numberClass,
NumberFormat format)
|
BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign,
Class numberClass,
NumberFormat format,
NumberFormat unformat)
|
Methods inherited from class javax.swing.JTextField |
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffset |
Methods inherited from class javax.swing.text.JTextComponent |
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write |
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, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, 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, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, 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, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
DEFAULT_FORMAT
public static final NumberFormat DEFAULT_FORMAT
DEFAULT_UNFORMAT
public static final NumberFormat DEFAULT_UNFORMAT
symbols
public static final DecimalFormatSymbols symbols
BigDecimalTextField
public BigDecimalTextField()
- Default constructor.
BigDecimalTextField
public BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign)
- See Also:
BigDecimalTextField(int, int, boolean, Class, NumberFormat,
NumberFormat)
BigDecimalTextField
public BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign,
Class numberClass)
- See Also:
BigDecimalTextField(int, int, boolean, Class, NumberFormat,
NumberFormat)
BigDecimalTextField
public BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign,
Class numberClass,
NumberFormat format)
- See Also:
BigDecimalTextField(int, int, boolean, Class, NumberFormat,
NumberFormat)
BigDecimalTextField
public BigDecimalTextField(int nrOfNonDecimals,
int nrOfDecimals,
boolean negativeSign,
Class numberClass,
NumberFormat format,
NumberFormat unformat)
- Parameters:
nrOfNonDecimals
- Number of non-decimals.nrOfDecimals
- Number of decimals.negativeSign
- Negative numbers allowed.numberClass
- Class type (default BigDecimal).format
- The "read"-format.unformat
- The "edit"-format.
addUserInputListener
public void addUserInputListener(UserInputListener listener)
- Add a UserInputListener.
- Parameters:
listener
- UserInputListener.- See Also:
UserInputListener
removeUserInputListener
public void removeUserInputListener(UserInputListener listener)
- Remove a UserInputListener.
- Parameters:
listener
- UserInputListener.- See Also:
UserInputListener
getValue
public Number getValue()
- Parses a number from the inputField and will adjust it's class if needed.
- Returns:
- Number the Parsed number.
setValue
public void setValue(Number number)
- Format the number and show it.
- Parameters:
number
- Number to set.
getScale
public Integer getScale()
- Returns:
- Returns the scale.
setScale
public void setScale(Integer scale)
- Parameters:
scale
- The scale to set.
Copyright © 2004-2008 The Spring Framework. All Rights Reserved.