jcontrol.ui.wombat
Class Frame

java.lang.Object
  extended by jcontrol.ui.wombat.Component
      extended by jcontrol.ui.wombat.Frame
All Implemented Interfaces:
EventListener, KeyListener, IContainer, IFrame

public class Frame
extends Component
implements IFrame, KeyListener

A Frame is the starting point for creating a graphical user interface. Only one frame instance should exist in an application.
An instance of this class should be used to create a keyboard and touch screen based application.

(C) DOMOLOGIC Home Automation GmbH 2005 - 2007

See Also:
IFrame, jcontrol.ui.wombat.TouchFrame, jcontrol.ui.wombat.FocusFrame

Field Summary
static XGraphics graphics
           
static Keyboard keyboard
          Keyboard access
static IPointingDevice pointingDevice
           
 
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
 
Constructor Summary
Frame()
           Constructs a new Frame.
Frame(XGraphics graphics, Keyboard keys, IPointingDevice pointingDevice)
           Constructs a new Frame.
 
Method Summary
 void add(Component component)
          Deprecated.  
 void clearFocus(IContainer icontainer)
          Clears the focus tree under the specified container.
 Container getContent()
          Returns the current content or null if there is none.
 Component getOutline()
          Returns the current outline or null if there is none.
 int onEvent(IContainer container, Event event)
           
 KeyEvent onKeyEvent(KeyEvent e)
          This method is called when a key has been pressedon the keyboard.
 void remove(Component component)
          Deprecated.  
 void removeAll()
          Deprecated.  
 void repaint()
          Causes the entire component to be marked as needing to be redrawn.
 boolean requestFocus(Component c)
          Tries to transfer the keyboard focus to the given component.
 void setBackgroundColor(Color bg)
          Sets the background color for this component.
 void setBuzzerParams(int hiFreq, int loFreq, int length)
           
 void setContent(Container container)
           Sets/replaces the frame's content.
 boolean setDirty(Object source, int x, int y, int width, int height, int state, boolean b)
          Marks all components inside this container that intersect the given bounds to be repainted.
 void setFont(Resource font)
          Sets the font for this component.
 void setForegroundColor(Color fg)
          Sets the foreground color for this component.
 void setOutline(Component component)
          Sets a static element on the frame.
 void setTransparentColor(Color transparentColor)
          Sets the transparent color for this component.
 void setVisible(boolean visible)
          Turns the component visible or invisible.
 boolean transferFocus(IContainer c, int direction)
          Transfers the focus in the given container to the next IFocusable element.
 void update(XGraphics g)
          Paint all components or a menu.
 
Methods inherited from class jcontrol.ui.wombat.Component
drawDisabledImage, getFrame, isEnabled, isVisible, isVisibleInternal, paint, redrawInternalAndParent, repaintAll, safeExec, setBackgroundColorInternal, setBounds, setDirty, setEnabled, setForegroundColorInternal, setParametersInternal, setRedraw, unsafeExec
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Field Detail

keyboard

public static Keyboard keyboard
Keyboard access


pointingDevice

public static IPointingDevice pointingDevice

graphics

public static XGraphics graphics
Constructor Detail

Frame

public Frame()

Constructs a new Frame.

The dimensions are equivalent to the display size. They may be changed by using setBounds().


Frame

public Frame(XGraphics graphics,
             Keyboard keys,
             IPointingDevice pointingDevice)

Constructs a new Frame.

The dimensions are equivalent to the display size. They may be changed by using setBounds().

Parameters:
graphics - An instance of a custom display adapter.
If this parameter is null, this application will not have keyboard support.
keys - An instance of a keyboard interface.
pointingDevice - An instance of a pointing device, e.g. jcontrol.io.Touch, or null.
If this parameter is null, this application will not have touch support.
Method Detail

setBuzzerParams

public void setBuzzerParams(int hiFreq,
                            int loFreq,
                            int length)

setVisible

public void setVisible(boolean visible)
Description copied from class: Component
Turns the component visible or invisible.

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

onEvent

public int onEvent(IContainer container,
                   Event event)

requestFocus

public boolean requestFocus(Component c)
Description copied from interface: IFrame
Tries to transfer the keyboard focus to the given component. This method is for internal use and should not be called by the application. This method may be empty in some frame implementations.

Specified by:
requestFocus in interface IFrame
Parameters:
c - the component to transfer the focus to
Returns:
true if this method was successful
See Also:
IFocusable.requestFocus()

transferFocus

public boolean transferFocus(IContainer c,
                             int direction)
Description copied from interface: IFrame
Transfers the focus in the given container to the next IFocusable element. This method is for internal use and should not be called by the application. This method may be empty in some frame implementations.

Specified by:
transferFocus in interface IFrame
Parameters:
c - the container
direction - IFocusable.TRANSFER_FOCUS_FORWARD or IFocusable.TRANSFER__FOCUS_BACKWARD

clearFocus

public void clearFocus(IContainer icontainer)
Description copied from interface: IFrame
Clears the focus tree under the specified container. This method is for internal use and should not be called by the application.

Specified by:
clearFocus in interface IFrame
Parameters:
icontainer - a container

update

public void update(XGraphics g)
Paint all components or a menu.

Overrides:
update in class Component
Parameters:
g - the application's graphics object.

setDirty

public boolean setDirty(Object source,
                        int x,
                        int y,
                        int width,
                        int height,
                        int state,
                        boolean b)
Description copied from interface: IContainer
Marks all components inside this container that intersect the given bounds to be repainted. This method should not be used by any application.

Specified by:
setDirty in interface IContainer
state - the state to set
Returns:
TODO

add

public void add(Component component)
Deprecated. 

Description copied from interface: IContainer
Adds a component to this IContainer

Specified by:
add in interface IContainer
Parameters:
component - the component to add.
See Also:
IContainer.add(jcontrol.ui.wombat.Component)

remove

public void remove(Component component)
Deprecated. 

Description copied from interface: IContainer
Removes a component from this IContainer.

Specified by:
remove in interface IContainer
Parameters:
component - the component to remove
See Also:
IContainer.remove(jcontrol.ui.wombat.Component)

removeAll

public void removeAll()
Deprecated. 

Description copied from interface: IContainer
Removes all components from this IContainer.

Specified by:
removeAll in interface IContainer
See Also:
IContainer.removeAll()

setContent

public void setContent(Container container)
Description copied from interface: IFrame

Sets/replaces the frame's content. Setting this value to null will destroy the current content. All handles within the current content will be reset to pave the way for the garbage collector. In this case, the frame's content will be null until this method is called again with a new container instance as argument or until the add(Component) method is called. In this case a new default content will be created internally.
As the content is the application's root container, this method can easily be used to implement a multi-page application by creating a number of containers, one for each page. Calling this method with any container instance will erase the whole display content and replace it with the new one. A good idea to reduce memory consumption is to set the old content to null before creating a new one. Thus, the garbage collector can release all memory resources that have been used by the old content before the new container is created that maybe needs this memory.

Example:
 public class FirstPage extends Container {
        public FirstPage() {
                super(2);
                // create some components here
                add(new Button("OK", ...);
                add(new Button("Cancel", ...);
        }
 }
     
 public class SecondPage extends Container {
        public SecondPage() {
                super(2);
                // create some other components here
                add(new Button("Abort", ...);
                add(new Button("Retry", ...);
        }
 }
     
 // important part of the main Application
 public class PageDemo extends Frame {
 
        public PageDemo() {
                // set first page as content 
                setContent(new FirstPage());
                // make the frame visible
                setVisible(true); 
                ...
                // some code
                ...
                // delete current content
                setContent(null);
                // now, it's time for the garbage collector to work
 
                // switch to second page
                setContent(new SecondPage());
        }
 }
 

Specified by:
setContent in interface IFrame
Parameters:
container - a container instance or null.

getContent

public Container getContent()
Description copied from interface: IFrame
Returns the current content or null if there is none.

Specified by:
getContent in interface IFrame
Returns:
the current content or null if there is none.

repaint

public void repaint()
Description copied from class: Component
Causes the entire component to be marked as needing to be redrawn. The next time a paint request is processed, the component will be painted completely.
Note that this method will have no effect if the component is already marked to be redrawn. Thus, e.g. after adding, changing, etc., components are marked dirty anyway. An additional repaint-call will make no sense in this case.

Overrides:
repaint in class Component

setOutline

public void setOutline(Component component)
Description copied from interface: IFrame
Sets a static element on the frame. The static element of a frame can be e.g. a clock or a logo or whatever. It will not disappear when the content changes.

Specified by:
setOutline in interface IFrame
Parameters:
component - a component to use as static element on the frame.

onKeyEvent

public KeyEvent onKeyEvent(KeyEvent e)
This method is called when a key has been pressedon the keyboard. The KeyEvent object is passed down through the component tree to the current focus component that may consume the event or force the frame to transfer the keyboard focus to the next component.
This method may be overwritten if any user specified keyboard behaviour is desired. In this case, the standard focus based keyboard functionality will no longer work.

Specified by:
onKeyEvent in interface KeyListener
Parameters:
e - The key event.
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.
See Also:
KeyListener.onKeyEvent(jcontrol.ui.wombat.event.KeyEvent)

setFont

public void setFont(Resource font)
Description copied from class: Component
Sets the font for this component.

Overrides:
setFont in class Component
Parameters:
font - the new font.

setForegroundColor

public void setForegroundColor(Color fg)
Description copied from class: Component
Sets the foreground color for this component.

Overrides:
setForegroundColor in class Component
Parameters:
fg - the foreground color to set

setTransparentColor

public void setTransparentColor(Color transparentColor)
Description copied from class: Component
Sets the transparent color for this component. Transparent color is optional and will be used in components that have "transparent" areas. E.g. the round corners of buttons and borders or radio buttons where the main background shines through. If a transparent color for those components is set it will be used instead of the component's background color in the "transparent" areas.

Overrides:
setTransparentColor in class Component
Parameters:
transparentColor - the transparent color to set

setBackgroundColor

public void setBackgroundColor(Color bg)
Description copied from class: Component
Sets the background color for this component.

Overrides:
setBackgroundColor in class Component
Parameters:
bg - the background color to set

getOutline

public Component getOutline()
Description copied from interface: IFrame
Returns the current outline or null if there is none.

Specified by:
getOutline in interface IFrame
Returns:
the current outline or null if there is none.