fds.micro.ui
Class Component

java.lang.Object
  extended byfds.micro.ui.Component
Direct Known Subclasses:
Button, CheckBox, ExclusiveChoice, GraphicItem, Hyperlink, ImageItem, Slider, StringItem, TextField

public abstract class Component
extends java.lang.Object

This class defines a root object for UI components present in package fds.micro.ui.

Warning: DO NOT USE this package for standard interfaces, or if your want a standard rendering and behaviour. All components defined here have been written to provide rendering control to the programmer. Use them when a sexy interface is vital and you don't mind of complex features.
In all other cases, use sub-classes of javax.microedition.lcdui.Item.

Basically, a component have a graphic implementation, is located at a specific position, and have width and height determined at rendering time. We can also specify a maximum width and height to make sure the component doesn't take too much space. Finally, a component can have the focus and must graphicaly render this kind of behaviour.

A component is dedicated to be used in a sub-class of fds.micro.ui.AbstractPanel.

If you want to write your own component you must respect following rules:

Author:
Frédéric DE STEUR
See Also:
AbstractPanel

Field Summary
static int INTERN_BOTTOM_VALIGN
          Vertically aligns parts within a component on the bottom of component border.
static int INTERN_CENTER_HALIGN
          Horizontally centers parts within a component.
static int INTERN_CENTER_VALIGN
          Vertically centers parts within a component.
static int INTERN_LEFT_HALIGN
          Horizontally aligns parts within a component on the left of component border.
static int INTERN_RIGHT_HALIGN
          Horizontally aligns parts within a component on the right of component border.
static int INTERN_TOP_VALIGN
          Vertically aligns parts within a component on the top of component border.
 
Constructor Summary
Component()
           
 
Method Summary
 void addFocusListener(FocusListener listener)
          Add a listener object that will receive focus events produced by this component.
 void addItemListener(ComponentListener listener)
          Add a listener object that will receive component events produced by this component.
 boolean equals(java.lang.Object obj)
           
 int getHAlign()
          Get the current horizontal alignment between this component parts.
 int getHeight()
           
 AbstractPanel getParent()
          Get the parent container.
 int getVAlign()
          Get the current vertical alignment between this component parts.
 int getWidth()
           
 int getX()
           
 int getY()
           
 boolean isDisabled()
          Get the flag that indicates if component is disabled.
 boolean isHaveFocus()
           
 boolean isHidden()
          Get the visible state of the component.
 boolean isManageFocus()
           
 boolean isOpaque()
          Get the opaque flag.
abstract  void keyPressed(int keyCode, int gameAction)
          Called to notify the component that a key is pressed.
abstract  void pointerPressed(int xpos, int ypos)
          Called to notify the component that pointer device was pressed.
 void removeFocusListener(FocusListener listener)
          Remove a focus listener.
 void removeItemListener(ComponentListener listener)
          Remove an component listener.
 void setBackground(int red, int green, int blue)
          Set the component background color (under the component itself).
 void setDisabled(boolean disabled)
          Disable/enable the component.
 void setFocusColor(int red, int green, int blue)
          Set the color used to render the focus.
 void setHAlign(int hAlign)
          Change the horizontal alignment between this component parts.
 void setHidden(boolean hidden)
          Hide or show the component.
 void setLocation(int x, int y)
           
 void setManageFocus(boolean manageFocus)
          Specify if want want the component to manage focus.
WARNING: Do not use this feature if your application can run on a platform without pointing device.
 void setMaximumSize(int width, int height)
          Set the maximum size for this component.
 void setOpaque(boolean opaque)
          Set a new value for opaque flag.
 void setVAlign(int vAlign)
          Change the vertical alignment between this component parts.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERN_BOTTOM_VALIGN

public static final int INTERN_BOTTOM_VALIGN
Vertically aligns parts within a component on the bottom of component border.

See Also:
Constant Field Values

INTERN_CENTER_HALIGN

public static final int INTERN_CENTER_HALIGN
Horizontally centers parts within a component.

See Also:
Constant Field Values

INTERN_CENTER_VALIGN

public static final int INTERN_CENTER_VALIGN
Vertically centers parts within a component.

See Also:
Constant Field Values

INTERN_LEFT_HALIGN

public static final int INTERN_LEFT_HALIGN
Horizontally aligns parts within a component on the left of component border.

See Also:
Constant Field Values

INTERN_RIGHT_HALIGN

public static final int INTERN_RIGHT_HALIGN
Horizontally aligns parts within a component on the right of component border.

See Also:
Constant Field Values

INTERN_TOP_VALIGN

public static final int INTERN_TOP_VALIGN
Vertically aligns parts within a component on the top of component border.

See Also:
Constant Field Values
Constructor Detail

Component

public Component()
Method Detail

addFocusListener

public void addFocusListener(FocusListener listener)
Add a listener object that will receive focus events produced by this component.

Parameters:
listener - The listener to add.

addItemListener

public void addItemListener(ComponentListener listener)
Add a listener object that will receive component events produced by this component.

Parameters:
listener - The listener to add.

equals

public boolean equals(java.lang.Object obj)
Returns:
In this implementation, this method returns true if given object IS the current one.
See Also:
Object.equals(java.lang.Object)

getHAlign

public int getHAlign()
Get the current horizontal alignment between this component parts.

Returns:
Returns the component horizontal alignment policy for internal parts. Can be values INTERN_LEFT_HALIGN, INTERN_CENTER_HALIGN (default) or INTERN_RIGHT_HALIGN.

getHeight

public int getHeight()
Returns:
The component height.

getParent

public AbstractPanel getParent()
Get the parent container.

Returns:
Returns the parent container.

getVAlign

public int getVAlign()
Get the current vertical alignment between this component parts.

Returns:
Returns the component vertical alignment policy for internal parts. Can be values INTERN_TOP_VALIGN, INTERN_CENTER_VALIGN (default) or INTERN_BOTTOM_VALIGN.

getWidth

public int getWidth()
Returns:
The component width.

getX

public int getX()
Returns:
The x position.

getY

public int getY()
Returns:
The y position.

isDisabled

public boolean isDisabled()
Get the flag that indicates if component is disabled.

Returns:
Returns true if component is disabled, and false if the component is enabled.

isHaveFocus

public boolean isHaveFocus()
Returns:
Returns true if the component have the focus.

isHidden

public boolean isHidden()
Get the visible state of the component.

Returns:
Returns true if component is hidden, and false if component is shown.

isManageFocus

public boolean isManageFocus()
Returns:
Returns true if this component manages the focus.

isOpaque

public boolean isOpaque()
Get the opaque flag.

Returns:
Returns true if the component paints a background.

keyPressed

public abstract void keyPressed(int keyCode,
                                int gameAction)
Called to notify the component that a key is pressed.

Parameters:
keyCode - The key code.
gameAction - Game action corresponding to the key code.

pointerPressed

public abstract void pointerPressed(int xpos,
                                    int ypos)
Called to notify the component that pointer device was pressed.

Parameters:
xpos - The X position of pointer on parent Canvas.
ypos - The Y position of pointer on parent Canvas.

removeFocusListener

public void removeFocusListener(FocusListener listener)
Remove a focus listener.

Parameters:
listener - The listener to remove.

removeItemListener

public void removeItemListener(ComponentListener listener)
Remove an component listener.

Parameters:
listener - The listener to remove.

setBackground

public void setBackground(int red,
                          int green,
                          int blue)
Set the component background color (under the component itself).

Parameters:
red - The red component of the color to set.
green - The green component of the color to set.
blue - The blue component of the color to set.

setDisabled

public void setDisabled(boolean disabled)
Disable/enable the component.

Parameters:
disabled - Must be true to disabled the component, and false enabled to enable it.

setFocusColor

public void setFocusColor(int red,
                          int green,
                          int blue)
Set the color used to render the focus.

Parameters:
red - The red component of the color to set.
green - The green component of the color to set.
blue - The blue component of the color to set.

setHAlign

public void setHAlign(int hAlign)
Change the horizontal alignment between this component parts.

Parameters:
hAlign - The component horizontal alignment policy for internal parts. Can take values INTERN_LEFT_HALIGN, INTERN_CENTER_HALIGN (default) or INTERN_RIGHT_HALIGN.

setHidden

public void setHidden(boolean hidden)
Hide or show the component.

Parameters:
hidden - Must be true to hide the component, and false to show it.

setLocation

public void setLocation(int x,
                        int y)
Parameters:
x - The x position.
y - The y position.

setManageFocus

public void setManageFocus(boolean manageFocus)
Specify if want want the component to manage focus.
WARNING: Do not use this feature if your application can run on a platform without pointing device. You were unable to interact with the component...

Parameters:
manageFocus - Must be true to indicates that this component manages the focus.

setMaximumSize

public void setMaximumSize(int width,
                           int height)
Set the maximum size for this component.

Parameters:
width - The maximum width.
height - The maximum height.

setOpaque

public void setOpaque(boolean opaque)
Set a new value for opaque flag.

Parameters:
opaque - Must be true for the component to paint a background.

setVAlign

public void setVAlign(int vAlign)
Change the vertical alignment between this component parts.

Parameters:
vAlign - The component vertical alignment policy for internal parts. Can take values INTERN_TOP_VALIGN, INTERN_CENTER_VALIGN (default) or INTERN_BOTTOM_VALIGN.