http://www.jpicedt.org

jpicedt.widgets
Class IncrementableTextField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jpicedt.widgets.IncrementableTextField
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class IncrementableTextField
extends JPanel

A 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.8 2013/03/27 06:49:26 vincentb1 Exp $
Author:
Sylvain Reynal
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
IncrementableTextField(double initialValue, double increment, Icon icon, String postFix)
          Creates a new IncrementableTextField with an etched border drawn around it.
IncrementableTextField(double initialValue, double increment, Icon icon, String postFix, boolean drawBorder)
           
IncrementableTextField(double initialValue, double increment, JLabel prefix, JLabel postfix, boolean drawBorder)
           
 
Method Summary
 void addActionListener(ActionListener l)
          adds an ActionListener to the component
protected  void fireActionPerformed()
          Notify all listeners that have registered interest for notification on this event type.
 String getActionCommand()
           
 double getMaximum()
           
 double getMinimum()
           
 double getValue()
           
 boolean isEnabled()
          Return the "enabled" state of this component
 boolean isHighBounded()
           
 boolean isLowBounded()
           
 void removeActionListener(ActionListener l)
          removes an ActionListener from the component
 void setActionCommand(String s)
          sets the actionCommand for this component to the given string
 void setBoundValues(double min, double max)
          sets minimum and maximum bounds for "value" to the given doubles
 void setDialogTitle(String title)
          sets the title of the JDialog that opens when a NumberFormatException occurs
 void setEnabled(boolean b)
          set the enable state of this component
 void setHighBounded(boolean state)
           
 void setLowBounded(boolean state)
           
 void setMaximum(double max)
          sets maximum bound for "value" to the given double
 void setMinimum(double min)
          sets minimum bound for "value" to the given double
 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.
 void setValue(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, 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, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IncrementableTextField

public IncrementableTextField(double initialValue,
                              double increment,
                              Icon icon,
                              String postFix)
Creates a new IncrementableTextField with an etched border drawn around it.

Parameters:
initialValue - the initial value of the text field
increment - increment by which value get in-/de-cremented when a click occurs on one of the two arrows
icon - if non-null, icon gets added to the left of the component
postFix - 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,
                              Icon icon,
                              String postFix,
                              boolean drawBorder)
Parameters:
initialValue - the initial value of the text field
increment - increment by which value get in-/de-cremented when a click occurs on one of the two arrows
icon - if non-null, gets added to the left of the component
postFix - 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,
                              JLabel prefix,
                              JLabel postfix,
                              boolean drawBorder)
Parameters:
initialValue - the initial value of the text field
increment - increment by which value get in-/de-cremented when a click occurs on one of the two arrows
prefix - if non-null, gets added to the left of the component
postfix - 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(String title)
sets the title of the JDialog that opens when a NumberFormatException occurs


setActionCommand

public void setActionCommand(String s)
sets the actionCommand for this component to the given string


getActionCommand

public 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(Number n)

setEnabled

public void setEnabled(boolean b)
set the enable state of this component

Overrides:
setEnabled in class JComponent

isEnabled

public boolean isEnabled()
Return the "enabled" state of this component

Overrides:
isEnabled in class 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(ActionListener l)
adds an ActionListener to the component


removeActionListener

public void removeActionListener(ActionListener l)
removes an ActionListener from the component


http://www.jpicedt.org

Submit a bug : syd@jpicedt.org