jMobileCore toolkit

com.jmobilecore.ui.core
Class Component

java.lang.Object
  extended by com.jmobilecore.ui.core.Component
Direct Known Subclasses:
ImageComponent, Label, SoftKeyBar, TextComponent, TextPane

public abstract class Component
extends java.lang.Object

A component is an object having a graphical representation that can be displayed on the screen and that can interact with the user. Examples of components are the buttons, checkboxes, and scrollbars of a typical graphical user interface.

The Component class is the abstract superclass of the User Interface components. Class Component can also be extended directly to create a custom component.

Author:
Greg Gridin

Field Summary
 int alignment
          The label's alignment.
 int background
          The background color for this component.
static int CENTER
          Indicates that the component should be centered.
 boolean focusable
           
 int focusedBackground
          The background color for this component when it focused.
 int focusedForeground
          The foreground color for this component when it focused.
protected  javax.microedition.lcdui.Font font
          The font used by this component.
 int foreground
          The foreground color for this component.
protected  int height
          The height of the component.
protected  boolean isCompletelyVisible
          Indicated if component is completely visible on the screen
protected  boolean isFocused
          Indicated if component is focusable
protected  boolean isVisible
          Indicated if component is completely or partially visible on the screen
static int LEFT
          Indicates that the component should be left justified.
protected  ScreenCanvas parentScreen
          The parent screen of the object.
static int RIGHT
          Indicates that the component should be right justified.
protected  int screenY
          Vertical offset in pixels of current component from top of the window
protected  boolean valid
          Indicated if component should be repainted
 int width
          The width of the component.
 
Constructor Summary
Component()
           
 
Method Summary
 void destructor()
          Default destructor.
 int getBackground()
          Get background
 javax.microedition.lcdui.Font getFont()
          Get the component's font
 int getForeground()
          Get foreground
 int getHeight()
          Returns the current height of this component.
 int getWidth()
          Returns the current width of this component.
 void invalidate()
          Invalidates this component.
 boolean isFocusOwner()
          Returns true if this Component is the focus owner.
protected  boolean keyPressed(int keyCode)
          Processes a press of a key.
protected  boolean keyReleased(int keyCode)
          Processes a release of a key.
protected  boolean keyRepeated(int keyCode)
          Processes when a key is repeated (held down).
 void paint(javax.microedition.lcdui.Graphics g)
          Paints this component.
protected  void paintBackground(javax.microedition.lcdui.Graphics g)
          Paints background for the component
protected  boolean pointerDragged(int x, int y)
          Processes when a pointer is dragged (held down).
protected  boolean pointerPressed(int x, int y)
          Processes a press of a pointer.
protected  boolean pointerReleased(int x, int y)
          Processes a release of a pointer.
protected  void prepareForeground(javax.microedition.lcdui.Graphics g)
          Prepares foreground for painting
 void releaseFocus()
           
 void requestFocus()
          Sets the focusable state of this Component to the specified value.
 void setFont(javax.microedition.lcdui.Font font)
          Sets the font of this component.
protected  void setHeight()
          Calculates the component height
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alignment

public int alignment
The label's alignment. The default alignment is set to be left justified.


background

public int background
The background color for this component.


CENTER

public static final int CENTER
Indicates that the component should be centered.

See Also:
Constant Field Values

focusable

public boolean focusable

focusedBackground

public int focusedBackground
The background color for this component when it focused.


focusedForeground

public int focusedForeground
The foreground color for this component when it focused.


font

protected javax.microedition.lcdui.Font font
The font used by this component. The font can be null.

See Also:
setFont(javax.microedition.lcdui.Font)

foreground

public int foreground
The foreground color for this component.


height

protected int height
The height of the component.


isCompletelyVisible

protected boolean isCompletelyVisible
Indicated if component is completely visible on the screen


isFocused

protected boolean isFocused
Indicated if component is focusable

See Also:
isFocusOwner(), requestFocus(), releaseFocus()

isVisible

protected boolean isVisible
Indicated if component is completely or partially visible on the screen


LEFT

public static final int LEFT
Indicates that the component should be left justified.

See Also:
Constant Field Values

parentScreen

protected ScreenCanvas parentScreen
The parent screen of the object.


RIGHT

public static final int RIGHT
Indicates that the component should be right justified.

See Also:
Constant Field Values

screenY

protected int screenY
Vertical offset in pixels of current component from top of the window


valid

protected boolean valid
Indicated if component should be repainted

See Also:
invalidate()

width

public int width
The width of the component.

Constructor Detail

Component

public Component()
Method Detail

destructor

public void destructor()
Default destructor. Helps VM to perform garbage collection


getBackground

public int getBackground()
Get background


getFont

public javax.microedition.lcdui.Font getFont()
Get the component's font

Returns:
the current font

getForeground

public int getForeground()
Get foreground


getHeight

public int getHeight()
Returns the current height of this component.

Returns:
the current height of this component

getWidth

public int getWidth()
Returns the current width of this component.

Returns:
the current width of this component

invalidate

public void invalidate()
Invalidates this component.


isFocusOwner

public boolean isFocusOwner()
Returns true if this Component is the focus owner.

Returns:
true if this Component is the focus owner; false otherwise

keyPressed

protected boolean keyPressed(int keyCode)
Processes a press of a key.


keyReleased

protected boolean keyReleased(int keyCode)
Processes a release of a key.


keyRepeated

protected boolean keyRepeated(int keyCode)
Processes when a key is repeated (held down).


paint

public void paint(javax.microedition.lcdui.Graphics g)
Paints this component.

Parameters:
g - the graphics context to use for painting

paintBackground

protected void paintBackground(javax.microedition.lcdui.Graphics g)
Paints background for the component

Parameters:
g - the Graphics context

pointerDragged

protected boolean pointerDragged(int x,
                                 int y)
Processes when a pointer is dragged (held down).


pointerPressed

protected boolean pointerPressed(int x,
                                 int y)
Processes a press of a pointer.


pointerReleased

protected boolean pointerReleased(int x,
                                  int y)
Processes a release of a pointer.


prepareForeground

protected void prepareForeground(javax.microedition.lcdui.Graphics g)
Prepares foreground for painting

Parameters:
g - the Graphics context

releaseFocus

public void releaseFocus()

requestFocus

public void requestFocus()
Sets the focusable state of this Component to the specified value. If component is not focusable then focusable state won't be changed

See Also:
isFocusOwner(), releaseFocus()

setFont

public void setFont(javax.microedition.lcdui.Font font)
Sets the font of this component.

Parameters:
font - the font to become this component's font; if this parameter is null then this component font won't be changed

setHeight

protected void setHeight()
Calculates the component height


jMobileCore toolkit