jcontrol.ui.wombat
Class AbstractFocusComponent

java.lang.Object
  extended by jcontrol.ui.wombat.Component
      extended by jcontrol.ui.wombat.AbstractFocusComponent
All Implemented Interfaces:
EventListener, ActionProducer, KeyListener, TouchListener, IFocusable
Direct Known Subclasses:
AbstractScrolledComponent, Button, CheckBox, KeyPad, Menu, NumberChooser, RadioButton, RockerSwitch, Slider, TextInputField, ToggleSwitch, TypeWriter

public abstract class AbstractFocusComponent
extends Component
implements IFocusable, TouchListener, ActionProducer

Abstract superclass for components that can be controlled by the keyboard.

(C) DOMOLOGIC Home Automation GmbH 2005 - 2007


Field Summary
protected static int BORDER_WIDTH
           
protected  ActionListener listener
           
 
Fields inherited from class jcontrol.ui.wombat.Component
backgroundColor, COLOR_COMPONENT_BACKGROUND, COLOR_COMPONENT_BACKGROUND_HIGHLIGHTED, COLOR_COMPONENT_DARK_SHADOW, COLOR_COMPONENT_FOREGROUND, COLOR_COMPONENT_FOREGROUND_INACTIVE, COLOR_COMPONENT_HIGHLIGHT_SHADOW, COLOR_COMPONENT_LIGHT_SHADOW, COLOR_COMPONENT_LIST_BACKGROUND, COLOR_COMPONENT_NORMAL_SHADOW, COLOR_COMPONENT_SELECTION_TEXT, COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND, COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND_INACTIVE, COLOR_COMPONENT_SELECTION_TEXT_INACTIVE, eventQueue, font, foregroundColor, frame, height, parent, RESERVED1, RESERVED2, RESERVED3, RESERVED4, RESERVED5, RESERVED6, state, STATE_ABORT_UPDATE, STATE_ANIMATED, STATE_BG_COLOR_SET, STATE_COVERED, STATE_DIRTY_MASK, STATE_DIRTY_PAINTALL, STATE_DIRTY_REPAINT, STATE_DIRTY_UPDATE, STATE_DISABLED, STATE_DISPOSED, STATE_FG_COLOR_SET, STATE_FOCUS, STATE_HEIGHT_FIXED, STATE_NO_REDRAW, STATE_REVALIDATE, STATE_SELECTED, STATE_SIZE_FIXED, STATE_UPDATED, STATE_VISIBLE, STATE_WIDTH_FIXED, transparentColor, width, x, y
 
Fields inherited from interface jcontrol.ui.wombat.IFocusable
TRANSFER_FOCUS_BACKWARD, TRANSFER_FOCUS_FORWARD
 
Fields inherited from interface jcontrol.ui.wombat.event.TouchListener
RESULT_ACCEPTED, RESULT_EXECUTED, RESULT_NONE
 
Constructor Summary
AbstractFocusComponent()
           
 
Method Summary
protected  void clearCorners(Graphics g, int x, int y, int width, int height, Color background)
           
protected  void drawBevelRect(XGraphics g, int x, int y, int width, int height, boolean shadowIn, boolean withFocus, Color background)
           
protected  void drawButton(XGraphics g, int x, int y, int width, int height, boolean pressed, boolean fill, Color background)
           
protected  void drawDottedRect(Graphics g, int x, int y, int width, int height)
          Draw a dotted rectangle.
protected  void drawFocusRect(Graphics g, int x, int y, int width, int height)
           
 ActionListener getActionListener()
          Returns the ActionListener of this Component.
protected  void onActionEvent(ActionEvent e)
          Pushes the ActionEvent to the global event queue.
abstract  KeyEvent onKeyEvent(KeyEvent event)
          This method is called when a keyboard action has been performed.
abstract  int onTouchEvent(TouchEvent event)
          Every time a touch event is fired, this method will be called.
 boolean requestFocus()
          Sets the focus to this Component.
 void setActionListener(ActionListener listener)
          Add an ActionListener to the component.
 void setEnabled(boolean enabled)
          Sets the enabled state of this component.
 void setVisible(boolean visible)
          Turns the component visible or invisible.
 
Methods inherited from class jcontrol.ui.wombat.Component
drawDisabledImage, getFrame, isEnabled, isVisible, isVisibleInternal, paint, redrawInternalAndParent, repaint, repaintAll, safeExec, setBackgroundColor, setBackgroundColorInternal, setBounds, setDirty, setFont, setForegroundColor, setForegroundColorInternal, setParametersInternal, setRedraw, setTransparentColor, unsafeExec, update
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Field Detail

BORDER_WIDTH

protected static final int BORDER_WIDTH
See Also:
Constant Field Values

listener

protected ActionListener listener
Constructor Detail

AbstractFocusComponent

public AbstractFocusComponent()
Method Detail

drawButton

protected void drawButton(XGraphics g,
                          int x,
                          int y,
                          int width,
                          int height,
                          boolean pressed,
                          boolean fill,
                          Color background)

clearCorners

protected void clearCorners(Graphics g,
                            int x,
                            int y,
                            int width,
                            int height,
                            Color background)

drawBevelRect

protected void drawBevelRect(XGraphics g,
                             int x,
                             int y,
                             int width,
                             int height,
                             boolean shadowIn,
                             boolean withFocus,
                             Color background)

drawFocusRect

protected void drawFocusRect(Graphics g,
                             int x,
                             int y,
                             int width,
                             int height)

drawDottedRect

protected void drawDottedRect(Graphics g,
                              int x,
                              int y,
                              int width,
                              int height)
Draw a dotted rectangle.


onTouchEvent

public abstract int onTouchEvent(TouchEvent event)
Description copied from interface: TouchListener
Every time a touch event is fired, this method will be called.

Specified by:
onTouchEvent in interface TouchListener
Parameters:
event - The touch event.
Returns:
RESULT_ACCEPTED if the TouchEvent has been consumed by the TouchListener,
RESULT_EXECUTED if the TouchEvent has been consumed by the TouchListener and some important action has been performed, e.g. an action event has been invoked,
RESULT_NONE if the TouchEvent should be passed on to the next TouchListener.

setActionListener

public void setActionListener(ActionListener listener)
Add an ActionListener to the component. It will receive ActionEvents when the component is selected.

Specified by:
setActionListener in interface ActionProducer
Parameters:
listener - an ActionListener

getActionListener

public ActionListener getActionListener()
Returns the ActionListener of this Component.

Specified by:
getActionListener in interface ActionProducer
Returns:
the ActionListener of this Component.

onKeyEvent

public abstract KeyEvent onKeyEvent(KeyEvent event)
This method is called when a keyboard action has been performed.

Specified by:
onKeyEvent in interface KeyListener
Parameters:
event - the event that contains information about the key.
Returns:
null if the KeyEvent has been consumed by the KeyListener,
or the the specified KeyEvent if it should be passed on to the next KeyListener.

onActionEvent

protected void onActionEvent(ActionEvent e)
Pushes the ActionEvent to the global event queue.

Parameters:
e - the ActionEvent

requestFocus

public boolean requestFocus()
Sets the focus to this Component.

Specified by:
requestFocus in interface IFocusable
Returns:
true if the component has got the focus.

setVisible

public void setVisible(boolean visible)
Turns the component visible or invisible.

Overrides:
setVisible in class Component
Parameters:
visible - the visible state to set.

setEnabled

public void setEnabled(boolean enabled)
Sets the enabled state of this component. Disabled components are no longer able to receive user (keyboard or touch) input. Some components get a "grayed" look in disabled state.

Overrides:
setEnabled in class Component
Parameters:
enabled - the enabled state.