org.havi.ui
Class HToggleButton

java.lang.Object
  extended byjava.awt.Component
      extended byorg.havi.ui.HComponent
          extended byorg.havi.ui.HVisible
              extended byorg.havi.ui.HStaticIcon
                  extended byorg.havi.ui.HIcon
                      extended byorg.havi.ui.HGraphicButton
                          extended byorg.havi.ui.HToggleButton
All Implemented Interfaces:
HActionable, HActionInputPreferred, HMatteLayer, HNavigable, HNavigationInputPreferred, HNoInputPreferred, HState, HSwitchable, java.awt.image.ImageObserver, java.io.Serializable, TestOpacity

public class HToggleButton
extends HGraphicButton
implements HSwitchable

The HToggleButton is a user interface component representing a "check box", or with the support of the HToggleGroup class, "radio buttons". It displays static read-only graphical content. This component can be navigated to, i.e. it can have the input focus, and it can be actioned as defined by the HSwitchable interface. This means that the interaction state persists after HActionEvent event processing is complete.

The current switchable state can be manipulated using setSwitchableState(boolean) and getSwitchableState()

By default it uses the HGraphicLook class to render itself.


The parameters to the constructors are as follows, in cases where parameters are not used, then the constructor should use the default values.

Default parameter values exposed in the constructors

ParameterDescriptionDefault value Set methodGet method
x x-coordinate of top left hand corner of this component in pixels, relative to its parent container (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
y y-coordinate of top left hand corner of this component in pixels, relative to its parent container (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
width width of this component in pixels (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
height height of this component in pixels (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
image The image to be used as the content for every state of this component. null setGraphicContent getGraphicContent
imageNormal The image to be used as the content for the HState.NORMAL_STATE state of this component. null setGraphicContent getGraphicContent
imageFocused The image to be used as the content for the HState.FOCUSED_STATE and HState.DISABLED_FOCUSED_STATE states of this component. null setGraphicContent getGraphicContent
imageActioned The image to be used as the content for the HState.ACTIONED_FOCUSED_STATE and HState.DISABLED_ACTIONED_FOCUSED_STATE states of this component. null setGraphicContent getGraphicContent
imageNormalActioned The image to be used as the content for the HState.ACTIONED_STATE and HState.DISABLED_ACTIONED_STATE states of this component. null setGraphicContent getGraphicContent
state The switchable state of this HToggleButton. false setSwitchableState(boolean) getSwitchableState()
group The HToggleGroup with which to associate this HToggleButton. null setToggleGroup(org.havi.ui.HToggleGroup) getToggleGroup()

Default parameter values not exposed in the constructors

DescriptionDefault valueSet method Get method
Associated matte (HMatte). none (i.e. getMatte() returns null) setMatte getMatte
The text layout manager responsible for text formatting. An HDefaultTextLayoutManager object. HVisible.setTextLayoutManager(org.havi.ui.HTextLayoutManager) HVisible.getTextLayoutManager()
The background painting mode HVisible.NO_BACKGROUND_FILL HVisible.setBackgroundMode(int) HVisible.getBackgroundMode()
The default preferred size not set (i.e. NO_DEFAULT_SIZE) unless specified by width and height parameters HVisible.setDefaultSize(java.awt.Dimension) HVisible.getDefaultSize()
The horizontal content alignment HVisible.HALIGN_CENTER HVisible.setHorizontalAlignment(int) HVisible.getHorizontalAlignment()
The vertical content alignment HVisible.VALIGN_CENTER HVisible.setVerticalAlignment(int) HVisible.getVerticalAlignment()
The content scaling mode HVisible.RESIZE_NONE HVisible.setResizeMode(int) HVisible.getResizeMode()
The border mode true HVisible.setBordersEnabled(boolean) HVisible.getBordersEnabled()
The default "look" for this class. A platform specific HGraphicLook HToggleButton.setDefaultLook HToggleButton.getDefaultLook
The "look" for this object. The HGraphicLook returned from HToggleButton.getDefaultLook when this object was created. HToggleButton.setLook HToggleButton.getLook
The gain focus sound. null setGainFocusSound getGainFocusSound
The lose focus sound. null setLoseFocusSound getLoseFocusSound
The action sound. null setActionSound getActionSound
The unset action sound. null setUnsetActionSound getUnsetActionSound

See Also:
HStaticIcon, HIcon, HNavigable, HActionable, HSwitchable, Serialized Form

Field Summary
 
Fields inherited from class org.havi.ui.HVisible
ADJUSTMENT_VALUE_CHANGE, ANIMATE_CONTENT_CHANGE, ANIMATION_POSITION_CHANGE, BACKGROUND_FILL, BORDER_CHANGE, CARET_POSITION_CHANGE, CONTENT_CHANGE, ECHO_CHAR_CHANGE, EDIT_MODE_CHANGE, FIRST_CHANGE, GRAPHIC_CONTENT_CHANGE, HALIGN_CENTER, HALIGN_JUSTIFY, HALIGN_LEFT, HALIGN_RIGHT, ITEM_VALUE_CHANGE, LAST_CHANGE, LIST_CONTENT_CHANGE, LIST_ICONSIZE_CHANGE, LIST_LABELSIZE_CHANGE, LIST_MULTISELECTION_CHANGE, LIST_SCROLLPOSITION_CHANGE, LIST_SELECTION_CHANGE, MIN_MAX_CHANGE, NO_BACKGROUND_FILL, NO_DEFAULT_HEIGHT, NO_DEFAULT_SIZE, NO_DEFAULT_WIDTH, ORIENTATION_CHANGE, REPEAT_COUNT_CHANGE, RESIZE_ARBITRARY, RESIZE_NONE, RESIZE_PRESERVE_ASPECT, SIZE_CHANGE, STATE_CHANGE, TEXT_CONTENT_CHANGE, TEXT_VALUE_CHANGE, THUMB_OFFSETS_CHANGE, UNKNOWN_CHANGE, VALIGN_BOTTOM, VALIGN_CENTER, VALIGN_JUSTIFY, VALIGN_TOP
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface org.havi.ui.HState
ACTIONED_FOCUSED_STATE, ACTIONED_STATE, ACTIONED_STATE_BIT, ALL_STATES, DISABLED_ACTIONED_FOCUSED_STATE, DISABLED_ACTIONED_STATE, DISABLED_FOCUSED_STATE, DISABLED_STATE, DISABLED_STATE_BIT, FIRST_STATE, FOCUSED_STATE, FOCUSED_STATE_BIT, LAST_STATE, NORMAL_STATE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
HToggleButton()
          Creates an HToggleButton object.
HToggleButton(java.awt.Image image)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image image, boolean state, HToggleGroup group)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image imageNormal, java.awt.Image imageFocused, java.awt.Image imageActioned, java.awt.Image imageNormalActioned, boolean state)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image imageNormal, java.awt.Image imageFocused, java.awt.Image imageActioned, java.awt.Image imageNormalActioned, boolean state, HToggleGroup group)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image imageNormal, java.awt.Image imageFocused, java.awt.Image imageActioned, java.awt.Image imageNormalActioned, int x, int y, int width, int height, boolean state)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image imageNormal, java.awt.Image imageFocused, java.awt.Image imageActioned, java.awt.Image imageNormalActioned, int x, int y, int width, int height, boolean state, HToggleGroup group)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image image, int x, int y, int width, int height)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image image, int x, int y, int width, int height, boolean state)
          Creates an HToggleButton object.
HToggleButton(java.awt.Image image, int x, int y, int width, int height, boolean state, HToggleGroup group)
          Creates an HToggleButton object.
 
Method Summary
static HGraphicLook getDefaultLook()
          Returns the currently set default HLook for HToggleButton components.
 boolean getSwitchableState()
          Returns the current switchable state of this HSwitchable.
 HToggleGroup getToggleGroup()
          Gets the HToggleGroup the HToggleButton is associated with.
 HSound getUnsetActionSound()
          Get the sound to be played when the interaction state of the HSwitchable makes the following transitions: ACTIONED_STATE to NORMAL_STATE ACTIONED_FOCUSED_STATE to FOCUSED_STATE
 void removeToggleGroup()
          Removes the button from the toggle group that it has been added to.
static void setDefaultLook(HGraphicLook hlook)
          Sets the default HLook for further HToggleButton components.
 void setSwitchableState(boolean state)
          Sets the current state of the button.
 void setToggleGroup(HToggleGroup group)
          Associates the HToggleButton with an HToggleGroup.
 void setUnsetActionSound(HSound sound)
          Associate a sound to be played when the interaction state of the HSwitchable makes the following transitions: ACTIONED_STATE to NORMAL_STATE ACTIONED_FOCUSED_STATE to FOCUSED_STATE
 
Methods inherited from class org.havi.ui.HGraphicButton
addHActionListener, addHFocusListener, getActionCommand, getActionSound, getGainFocusSound, getLoseFocusSound, getMove, getNavigationKeys, isSelected, processHActionEvent, processHFocusEvent, removeHActionListener, removeHFocusListener, setActionCommand, setActionSound, setFocusTraversal, setGainFocusSound, setLoseFocusSound, setMove
 
Methods inherited from class org.havi.ui.HStaticIcon
setLook
 
Methods inherited from class org.havi.ui.HVisible
getAnimateContent, getBackgroundMode, getBordersEnabled, getContent, getDefaultSize, getGraphicContent, getHorizontalAlignment, getInteractionState, getLook, getLookData, getMaximumSize, getMinimumSize, getPreferredSize, getResizeMode, getTextContent, getTextLayoutManager, getVerticalAlignment, isFocusTraversable, isOpaque, paint, setAnimateContent, setBackgroundMode, setBordersEnabled, setContent, setDefaultSize, setEnabled, setGraphicContent, setHorizontalAlignment, setInteractionState, setLookData, setResizeMode, setTextContent, setTextLayoutManager, setVerticalAlignment, update
 
Methods inherited from class org.havi.ui.HComponent
getMatte, isDoubleBuffered, isEnabled, processEvent, setMatte
 
Methods inherited from class java.awt.Component
addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, areFocusTraversalKeysSet, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, doLayout, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getCursor, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, hasFocus, imageUpdate, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusCycleRoot, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, list, list, list, list, list, paintAll, paramString, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, setBackground, setBounds, setBounds, setCursor, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.havi.ui.HActionable
addHActionListener, getActionSound, removeHActionListener, setActionCommand, setActionSound
 
Methods inherited from interface org.havi.ui.HNavigable
addHFocusListener, getGainFocusSound, getLoseFocusSound, getMove, isSelected, removeHFocusListener, setFocusTraversal, setGainFocusSound, setLoseFocusSound, setMove
 
Methods inherited from interface org.havi.ui.HNavigationInputPreferred
getNavigationKeys, processHFocusEvent
 
Methods inherited from interface org.havi.ui.HActionInputPreferred
getActionCommand, processHActionEvent
 

Constructor Detail

HToggleButton

public HToggleButton()
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image image,
                     int x,
                     int y,
                     int width,
                     int height)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image image)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image image,
                     int x,
                     int y,
                     int width,
                     int height,
                     boolean state)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image imageNormal,
                     java.awt.Image imageFocused,
                     java.awt.Image imageActioned,
                     java.awt.Image imageNormalActioned,
                     int x,
                     int y,
                     int width,
                     int height,
                     boolean state)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image imageNormal,
                     java.awt.Image imageFocused,
                     java.awt.Image imageActioned,
                     java.awt.Image imageNormalActioned,
                     boolean state)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image image,
                     int x,
                     int y,
                     int width,
                     int height,
                     boolean state,
                     HToggleGroup group)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image image,
                     boolean state,
                     HToggleGroup group)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image imageNormal,
                     java.awt.Image imageFocused,
                     java.awt.Image imageActioned,
                     java.awt.Image imageNormalActioned,
                     int x,
                     int y,
                     int width,
                     int height,
                     boolean state,
                     HToggleGroup group)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.


HToggleButton

public HToggleButton(java.awt.Image imageNormal,
                     java.awt.Image imageFocused,
                     java.awt.Image imageActioned,
                     java.awt.Image imageNormalActioned,
                     boolean state,
                     HToggleGroup group)
Creates an HToggleButton object. See the class description for details of constructor parameters and default values.

Method Detail

setToggleGroup

public void setToggleGroup(HToggleGroup group)
Associates the HToggleButton with an HToggleGroup. If this HToggleButton is already in a different HToggleGroup, it is first taken out of that group.

Parameters:
group - The HToggleGroup the HToggleButton is to be associated with.

getToggleGroup

public HToggleGroup getToggleGroup()
Gets the HToggleGroup the HToggleButton is associated with.

Returns:
The HToggleGroup the HToggleButton is associated with, or null if the HToggleButton is not associated with an HToggleGroup.

removeToggleGroup

public void removeToggleGroup()
Removes the button from the toggle group that it has been added to. This method does nothing if the button had not been previously added to an HToggleGroup.


setDefaultLook

public static void setDefaultLook(HGraphicLook hlook)
Sets the default HLook for further HToggleButton components.

Parameters:
hlook - The HLook that will be used by default when creating a new HToggleButton component. Note that this parameter may be null, in which case newly created components shall not draw themselves until a non-null look is set using the HStaticIcon.setLook(org.havi.ui.HLook) method.

getDefaultLook

public static HGraphicLook getDefaultLook()
Returns the currently set default HLook for HToggleButton components.

Returns:
The HLook that is used by default when creating a new HToggleButton component.

getSwitchableState

public boolean getSwitchableState()
Returns the current switchable state of this HSwitchable.

Specified by:
getSwitchableState in interface HSwitchable
Returns:
the current switchable state of this HSwitchable.

setSwitchableState

public void setSwitchableState(boolean state)
Sets the current state of the button. Note that ActionListeners are only called when an ACTION_PERFORMED event is received, or if they are called directly, e.g. via processActionEvent, they are not called by setSwitchableState.

Specified by:
setSwitchableState in interface HSwitchable

setUnsetActionSound

public void setUnsetActionSound(HSound sound)
Associate a sound to be played when the interaction state of the HSwitchable makes the following transitions:

Specified by:
setUnsetActionSound in interface HSwitchable
Parameters:
sound - a sound to be played when the HSwitchable transitions from an actioned state. If sound content is already set, the original content is replaced. To remove the sound specify a null HSound.

getUnsetActionSound

public HSound getUnsetActionSound()
Get the sound to be played when the interaction state of the HSwitchable makes the following transitions:

Specified by:
getUnsetActionSound in interface HSwitchable
Returns:
the sound to be played when the HSwitchable transitions from an actioned state.