org.gnu.gtk
Class SpinButton

java.lang.Object
  extended by org.gnu.glib.Struct
      extended by org.gnu.glib.GObject
          extended by org.gnu.gtk.GtkObject
              extended by org.gnu.gtk.Widget
                  extended by org.gnu.gtk.Entry
                      extended by org.gnu.gtk.SpinButton
All Implemented Interfaces:
Editable

public class SpinButton
extends Entry

A SpinButton widget displays a single numeric value that you can change by using the two arrow buttons to its right, or by editing the number directly.


Constructor Summary
SpinButton(Adjustment adjustment, double climbRate, int digits)
          Creates a new SpinButton
SpinButton(double min, double max, double step)
          Creates a new SpinButton without manually creating an adjustment.
SpinButton(org.gnu.glib.Handle handle)
          Construct a new SpinButton from a handle to a native resource.
 
Method Summary
 void addListener(SpinListener listener)
          Register an object to handle spin events.
 void configure(Adjustment adjustment, double climbRate, int digits)
          Changes the properties of an existing spin button.
 Adjustment getAdjustment()
          Returns the Adjustment object used with this object.
 java.lang.Class getEventListenerClass(java.lang.String signal)
           
 EventType getEventType(java.lang.String signal)
           
 int getIntValue()
          Returns the current value, as an integer.
static SpinButton getSpinButton(org.gnu.glib.Handle handle)
          Internal static factory method to be used by Java-Gnome only.
static Type getType()
          Retrieve the runtime type used by the GLib library.
 double getValue()
          Get the value of the SpinButton
 void removeListener(SpinListener listener)
          Removes a listener
 void setAdjustment(Adjustment adjustment)
          Replaces the adjustment object associated with the Spin button
 void setIncrements(double step, double page)
          Sets the step and page increments.
 void setNumeric(boolean numeric)
          Sets the flag that determines if non-numeric text can be typed in the spin button.
 void setPrecision(int digits)
          Set the precision to be displayed.
 void setRange(double min, double max)
          Sets the minimum and maximum allowable values
 void setSnap(boolean snapToTicks)
          Sets the policy as to whether values are corrected to the nearest step increment when a spin button is activated after providing an invalid value.
 void setUpdatePolicy(SpinButtonUpdatePolicy policy)
          Sets the update behavior of a spin button.
 void setValue(double value)
          Sets the value of the spin button
 void setWrap(boolean wrap)
          Sets the flag that determines if a spin button value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.
 void spin(SpinType direction, double increment)
          Increment or decrement a spin button's value in a specified direction by a specified amount.
 
Methods inherited from class org.gnu.gtk.Entry
addListener, copyClipboard, cutClipboard, deleteSelection, deleteText, getAlignment, getCharacters, getCompletion, getCursorPosition, getEditable, getEntry, getHasFrame, getLayout, getLayoutOffsets, getMaxLength, getText, getVisible, getWidth, handleToggleOverwrite, insertText, layoutIndexToTextIndex, pasteClipboard, removeListener, selectRegion, setActivateDefaultWidget, setAlignment, setCompletion, setCursorPosition, setEditable, setHasFrame, setInvisibleChar, setMaxLength, setText, setVisible, setWidth, textIndexToLayoutIndex
 
Methods inherited from class org.gnu.gtk.Widget
activate, addAccelerator, addEvents, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, canActivateAccel, createContext, createLayout, draw, drawArea, drawArea, finish, getAccessible, getAllocation, getCanFocus, getColormap, getContext, getData, getDisplay, getDragData, getExtensionEvents, getModifierStyle, getName, getParent, getParentWindow, getPointer, getRootWindow, getScreen, getSensitive, getStyle, getToplevel, getWidget, getWindow, grabDefault, grabFocus, hasFocus, hasScreen, hide, hideAll, highlight, highlight, intersect, isAncestor, makeWidget, modifyStyle, popColormap, pushColormap, realize, removeAccelerator, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, reparent, setBackgroundColor, setBaseColor, setCanFocus, setColormap, setDoubleBuffered, setDragDestination, setDragIcon, setDragIconPixbuf, setDragIconStock, setDragSource, setEvents, setExtensionEvents, setFont, setForegroundColor, setMinimumSize, setName, setNoDragDestination, setNoDragSource, setSensitive, setTextColor, shapeCombineMask, show, showAll, unHighlight, unHighlight
 
Methods inherited from class org.gnu.gtk.GtkObject
destroy, sink
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getPixbufProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify
 
Methods inherited from class org.gnu.glib.Struct
equals, getHandle, getNullHandle, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpinButton

public SpinButton(Adjustment adjustment,
                  double climbRate,
                  int digits)
Creates a new SpinButton

Parameters:
adjustment - The Adjustment object that this spin button should use.
climbRate - Specifies how much the spin button changes when an arrow is clicked on.
digits - The number of decimal places to display.

SpinButton

public SpinButton(double min,
                  double max,
                  double step)
Creates a new SpinButton without manually creating an adjustment. The value is initially set to the minimum value and a page increment of 10 * step is the default. The precision of the spin button is equivalent to the precision of step.

Parameters:
min - Minimum allowable value
max - Maximum allowable value
step - Increment added or subtracted by spinning the widget

SpinButton

public SpinButton(org.gnu.glib.Handle handle)
Construct a new SpinButton from a handle to a native resource.

Method Detail

getSpinButton

public static SpinButton getSpinButton(org.gnu.glib.Handle handle)
Internal static factory method to be used by Java-Gnome only.


configure

public void configure(Adjustment adjustment,
                      double climbRate,
                      int digits)
Changes the properties of an existing spin button. The adjustment, climb rate, and number of decimal places are all changed accordingly, after this function call.

Parameters:
adjustment - An Adjustment object to use.
climbRate - The new climb rate.
digits - The number of decimal places to display in the spin button.

setAdjustment

public void setAdjustment(Adjustment adjustment)
Replaces the adjustment object associated with the Spin button

Parameters:
adjustment - New adjustment object to use

getAdjustment

public Adjustment getAdjustment()
Returns the Adjustment object used with this object.

Returns:
the adjustment object for this SpinButton

setPrecision

public void setPrecision(int digits)
Set the precision to be displayed. Up to 20 digit precision is allowed.

Parameters:
digits - Number of digits to be displayed

setIncrements

public void setIncrements(double step,
                          double page)
Sets the step and page increments. This affects how quickly the value changes when the spin button's arrows are activated.

Parameters:
step - Increment applied for a button 1 press.
page - Increment applied for a button 2 press.

setRange

public void setRange(double min,
                     double max)
Sets the minimum and maximum allowable values

Parameters:
min - Minimum allowable value.
max - Maximum allowable value.

getIntValue

public int getIntValue()
Returns the current value, as an integer. The value is stored as a double - this method converts it to an integer. To get the raw double value, use getValue().

Returns:
Current value of SpinButton, as an integer

setValue

public void setValue(double value)
Sets the value of the spin button

Parameters:
value - The value for the SpinButton

setUpdatePolicy

public void setUpdatePolicy(SpinButtonUpdatePolicy policy)
Sets the update behavior of a spin button. This determines whether the spin button is always updated or only when a valid value is set.

Parameters:
policy - An update Policy

spin

public void spin(SpinType direction,
                 double increment)
Increment or decrement a spin button's value in a specified direction by a specified amount.

Parameters:
direction - A SpinType indicating the direction to spin.
increment - Step increment to apply in the specified direction.

setWrap

public void setWrap(boolean wrap)
Sets the flag that determines if a spin button value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.

Parameters:
wrap - If true, the value will wrap

setSnap

public void setSnap(boolean snapToTicks)
Sets the policy as to whether values are corrected to the nearest step increment when a spin button is activated after providing an invalid value.

Parameters:
snapToTicks - A flag indicating if invalid values should be corrected.

getValue

public double getValue()
Get the value of the SpinButton

Returns:
The current value

setNumeric

public void setNumeric(boolean numeric)
Sets the flag that determines if non-numeric text can be typed in the spin button.

Parameters:
numeric - Set the flag to true or false.

addListener

public void addListener(SpinListener listener)
Register an object to handle spin events.

See Also:
SpinListener

removeListener

public void removeListener(SpinListener listener)
Removes a listener

See Also:
addListener(SpinListener)

getEventListenerClass

public java.lang.Class getEventListenerClass(java.lang.String signal)
Overrides:
getEventListenerClass in class Entry

getEventType

public EventType getEventType(java.lang.String signal)
Overrides:
getEventType in class Entry

getType

public static Type getType()
Retrieve the runtime type used by the GLib library.