Class IncrementableTextField

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

    public class IncrementableTextField
    extends javax.swing.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.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
      • 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

      • 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
      • Fields inherited from class java.awt.Component

        accessibleContext, 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

      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
      void addActionListener​(java.awt.event.ActionListener l)
      adds an ActionListener to the component
      protected void fireActionPerformed()
      Notify all listeners that have registered interest for notification on this event type.
      java.lang.String getActionCommand()  
      double getMaximum()  
      double getMinimum()  
      double getValue()  
      boolean isEnabled()
      Return the "enabled" state of this component
      boolean isHighBounded()  
      boolean isLowBounded()  
      void removeActionListener​(java.awt.event.ActionListener l)
      removes an ActionListener from the component
      void setActionCommand​(java.lang.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​(java.lang.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​(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
      • 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,
                                      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 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,
                                      javax.swing.Icon icon,
                                      java.lang.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,
                                      javax.swing.JLabel prefix,
                                      javax.swing.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​(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:
        setEnabled in class javax.swing.JComponent
      • isEnabled

        public boolean isEnabled()
        Return the "enabled" state of this component
        Overrides:
        isEnabled in class java.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