Package jpicedt.widgets
Class IncrementableTextField
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- jpicedt.widgets.IncrementableTextField
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible
public class IncrementableTextField extends javax.swing.JPanelA JComponent that lump together a JSpinner (with a +/- arrow field that allows the user to increment/decrement) and prefix/postfix labels. the field's value.- Since:
- jpicedt 1.3
- Version:
- $Id: IncrementableTextField.java,v 1.6.2.1 2007/09/02 11:56:31 reynal Exp $
- Author:
- Sylvain Reynal
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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
-
-
Field Summary
-
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 Summary
Constructors Constructor Description IncrementableTextField(double initialValue, double increment, javax.swing.Icon icon, java.lang.String postFix)Creates a new IncrementableTextField with an etched border drawn around it.IncrementableTextField(double initialValue, double increment, javax.swing.Icon icon, java.lang.String postFix, boolean drawBorder)IncrementableTextField(double initialValue, double increment, javax.swing.JLabel prefix, javax.swing.JLabel postfix, boolean drawBorder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddActionListener(java.awt.event.ActionListener l)adds an ActionListener to the componentprotected voidfireActionPerformed()Notify all listeners that have registered interest for notification on this event type.java.lang.StringgetActionCommand()doublegetMaximum()doublegetMinimum()doublegetValue()booleanisEnabled()Return the "enabled" state of this componentbooleanisHighBounded()booleanisLowBounded()voidremoveActionListener(java.awt.event.ActionListener l)removes an ActionListener from the componentvoidsetActionCommand(java.lang.String s)sets the actionCommand for this component to the given stringvoidsetBoundValues(double min, double max)sets minimum and maximum bounds for "value" to the given doublesvoidsetDialogTitle(java.lang.String title)sets the title of the JDialog that opens when a NumberFormatException occursvoidsetEnabled(boolean b)set the enable state of this componentvoidsetHighBounded(boolean state)voidsetLowBounded(boolean state)voidsetMaximum(double max)sets maximum bound for "value" to the given doublevoidsetMinimum(double min)sets minimum bound for "value" to the given doublevoidsetValue(double value)sets the DecimalNumberField double value, as well as the internal copy, to the given value, possibly modifying it so that it fits within the limits.voidsetValue(java.lang.Number n)-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, 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, 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, setFocusTraversalKeys, setFont, 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, transferFocusDownCycle, validate, validateTree
-
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, 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
-
-
-
-
Constructor Detail
-
IncrementableTextField
public IncrementableTextField(double initialValue, double increment, javax.swing.Icon icon, java.lang.String postFix)Creates a new IncrementableTextField with an etched border drawn around it.- Parameters:
initialValue- the initial value of the text fieldincrement- increment by which value get in-/de-cremented when a click occurs on one of the two arrowsicon- if non-null, icon gets added to the left of the componentpostFix- if non-null, this string gets added just right of the testfield (it can be use to specify a unit)
-
IncrementableTextField
public IncrementableTextField(double initialValue, double increment, javax.swing.Icon icon, java.lang.String postFix, boolean drawBorder)- Parameters:
initialValue- the initial value of the text fieldincrement- increment by which value get in-/de-cremented when a click occurs on one of the two arrowsicon- if non-null, gets added to the left of the componentpostFix- if non-null, gets added just right of the component (it can be use to specify a unit)drawBorder- if TRUE, draw a border around the component
-
IncrementableTextField
public IncrementableTextField(double initialValue, double increment, javax.swing.JLabel prefix, javax.swing.JLabel postfix, boolean drawBorder)- Parameters:
initialValue- the initial value of the text fieldincrement- increment by which value get in-/de-cremented when a click occurs on one of the two arrowsprefix- if non-null, gets added to the left of the componentpostfix- if non-null, gets added just right of the component (it can be use to specify a unit)drawBorder- if TRUE, draw a border around the component
-
-
Method Detail
-
setBoundValues
public void setBoundValues(double min, double max)sets minimum and maximum bounds for "value" to the given doubles
-
setMinimum
public void setMinimum(double min)
sets minimum bound for "value" to the given double
-
setMaximum
public void setMaximum(double max)
sets maximum bound for "value" to the given double
-
getMaximum
public double getMaximum()
- Returns:
- the maximum bound
-
getMinimum
public double getMinimum()
- Returns:
- the minimum bound
-
setLowBounded
public void setLowBounded(boolean state)
- Parameters:
state- if TRUE, DecimalNumberField's value is low-bounded
-
isLowBounded
public boolean isLowBounded()
- Returns:
- TRUE if "value" is low-bounded
-
setHighBounded
public void setHighBounded(boolean state)
- Parameters:
state- if TRUE, DecimalNumberField's value is high-bounded
-
isHighBounded
public boolean isHighBounded()
- Returns:
- TRUE if "value" is high-bounded
-
setDialogTitle
public void setDialogTitle(java.lang.String title)
sets the title of the JDialog that opens when a NumberFormatException occurs
-
setActionCommand
public void setActionCommand(java.lang.String s)
sets the actionCommand for this component to the given string
-
getActionCommand
public java.lang.String getActionCommand()
- Returns:
- this component's action command
-
getValue
public double getValue()
- Returns:
- the current double value contained in DecimalNumberField
-
setValue
public void setValue(double value)
sets the DecimalNumberField double value, as well as the internal copy, to the given value, possibly modifying it so that it fits within the limits.
-
setValue
public void setValue(java.lang.Number n)
-
setEnabled
public void setEnabled(boolean b)
set the enable state of this component- Overrides:
setEnabledin classjavax.swing.JComponent
-
isEnabled
public boolean isEnabled()
Return the "enabled" state of this component- Overrides:
isEnabledin classjava.awt.Component
-
fireActionPerformed
protected void fireActionPerformed()
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
-
addActionListener
public void addActionListener(java.awt.event.ActionListener l)
adds an ActionListener to the component
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener l)
removes an ActionListener from the component
-
-