org.geotools.swt.control
Class JIntegerField

Object
  extended by Widget
      extended by Control
          extended by Scrollable
              extended by Text
                  extended by JValueField
                      extended by JIntegerField
All Implemented Interfaces:
EventListener, ModifyListener, Drawable, SWTEventListener

public class JIntegerField
extends JValueField
implements ModifyListener

A text field control to work with integer values. It can be constrained to positive values if desired.

Example of use:


 int initialValue = ...
 boolean allowNegatives = false;
 JIntegerField control = new JIntegerField(initialValue, allowNegatives);
 control.addValueChangedListener( new ValueChangedListener() {
     public void onValueChanged( ValueChangedEvent ev ) {
         System.out.println("The new value is " + ev.getValue());
     }
 });
 

Author:
Michael Bedward, Andrea Antonello (www.hydrologis.com)

Field Summary
 
Fields inherited from class Text
DELIMITER, LIMIT
 
Fields inherited from class Control
handle
 
Constructor Summary
JIntegerField(Composite parent, int style)
          Creates a new text field that allows negative values and has an initial value of 0.
JIntegerField(Composite parent, int style, boolean allowsNegative)
          Creates a new text field with an initial value of 0.
JIntegerField(Composite parent, int style, int value)
          Creates a new text field that allows negative values and the given initial value.
JIntegerField(Composite parent, int style, int value, boolean allowNegative)
          Creates a new text field with the given initial value.
 
Method Summary
 int getValue()
          Get the current value of this control.
 void modifyText(ModifyEvent arg0)
           
 void setValue(int value)
          Set the integer value of this control.
 void setValue(int value, boolean publishEvent)
          Set the integer value of this control, optionally skipping notification of the change to listeners.
 
Methods inherited from class JValueField
addValueChangedListener, fireValueChangedEvent, removeValueChangedListener
 
Methods inherited from class Text
addModifyListener, addSelectionListener, addVerifyListener, append, clearSelection, computeSize, computeTrim, copy, cut, getBorderWidth, getCaretLineNumber, getCaretLocation, getCaretPosition, getCharCount, getDoubleClickEnabled, getEchoChar, getEditable, getLineCount, getLineDelimiter, getLineHeight, getMessage, getOrientation, getSelection, getSelectionCount, getSelectionText, getTabs, getText, getText, getTextLimit, getTopIndex, getTopPixel, insert, paste, removeModifyListener, removeSelectionListener, removeVerifyListener, selectAll, setDoubleClickEnabled, setEchoChar, setEditable, setFont, setMessage, setOrientation, setRedraw, setSelection, setSelection, setSelection, setTabs, setText, setTextLimit, setTopIndex, showSelection
 
Methods inherited from class Scrollable
getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFocus, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
 
Methods inherited from class Widget
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JIntegerField

public JIntegerField(Composite parent,
                     int style)
Creates a new text field that allows negative values and has an initial value of 0.


JIntegerField

public JIntegerField(Composite parent,
                     int style,
                     boolean allowsNegative)
Creates a new text field with an initial value of 0.

Parameters:
allowNegative - true if this field should allow negative values to be entered; false if only positive values are allowed

JIntegerField

public JIntegerField(Composite parent,
                     int style,
                     int value)
Creates a new text field that allows negative values and the given initial value.

Parameters:
value - the initial value to display

JIntegerField

public JIntegerField(Composite parent,
                     int style,
                     int value,
                     boolean allowNegative)
Creates a new text field with the given initial value.

Parameters:
value - the initial value to display
allowNegative - true if this field should allow negative values to be entered; false if only positive values are allowed
Method Detail

getValue

public int getValue()
Get the current value of this control.

Returns:
the current value

setValue

public void setValue(int value)
Set the integer value of this control. A ValueChangedEvent will be published to all ValueChangedListeners.

Parameters:
value - the value to set
Throws:
IllegalArgumentException - if value is negative but the field only allows positive values

setValue

public void setValue(int value,
                     boolean publishEvent)
Set the integer value of this control, optionally skipping notification of the change to listeners.

This version is useful when two or more controls are synchronized (ie. changes to the value of one control results in changes to the values of other controls). In such a setting, firing change events can result in an endless cycle or a mutex violation.

Parameters:
value - the value to set
publishEvent - true to notify listeners of this change; false to skip notification
Throws:
IllegalArgumentException - if value is negative but the field only allows positive values

modifyText

public void modifyText(ModifyEvent arg0)
Specified by:
modifyText in interface ModifyListener


Copyright © 1996-2014 Geotools. All Rights Reserved.