moka.x
Class Component

java.lang.Object
  extended bymoka.lang.Object
      extended bymoka.event.EventListener
          extended bymoka.x.Component
Direct Known Subclasses:
Bevel, CaptionedComponent, Container, Image

public class Component
extends EventListener

Component is the base class for user-interface objects.

Since:
MDK1.0a

Field Summary
 boolean enabled
          Is the Component enabled ? Should be only read.
 short height
          The height of this Component.
 EventListener listen
          The event listener for this component.
 char mnemonic
          The mnemonic associated with this component.
protected  Component next
          The next component in the container of this Component.
protected  Container parent
          The parent Container of this Component.
protected  Component prev
          The previous component in the container of this Component.
 boolean visible
          Is the Component visible ? Should be only read.
 short width
          The width of this Component.
 short x
          The horizontal coordinate of this Component.
 short y
          The vertical coordinate of this Component.
 
Constructor Summary
Component()
          Constructs a newly allocated Component.
 
Method Summary
 void bottom()
           
 void center()
           
 void checkMnemonic(char m)
          Checks if the mnemonic of this component correspond to the current mnemonic.
protected  void clean()
          Disposes of all ressources used by this component.
 void eventTriggered(java.lang.Object sender)
          Invoked when an event is triggered.
 void finalize()
          Free the memory and system ressources used by this Component.
 boolean isCursorOver(short x, short y)
          Indicates if the cursor is over this component.
 void left()
           
 void move(short x, short y)
           
 void onPaint()
          Called when a PaintEvent occurs to paint the image of the component and stores it in its virtual memory.
 void paint()
          This method is called to draw the component.
 void right()
           
 void setBounds(short x, short y, short width, short height)
           
 void setEnabled(boolean b)
          Sets if the component is enabled or not.
 void setHeight(short height)
           
 void setMnemonic(char mnemonic)
          Sets the mnemonic for this component.
 void setVisible(boolean b)
          Sets the visibility of the component.
 void setWidth(short width)
           
 void setX(short x)
           
 void setY(short y)
           
 Component toFront(Component c)
          Called to brings a component to the front of a container.
 void top()
           
 void use()
          This method is invoked by the GEM when the user interacts with the component.
 
Methods inherited from class moka.event.EventListener
eventTriggered
 
Methods inherited from class moka.lang.Object
equals, getClassName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

protected Component next
The next component in the container of this Component.


prev

protected Component prev
The previous component in the container of this Component.


parent

protected Container parent
The parent Container of this Component.


height

public short height
The height of this Component. Should be only read.


width

public short width
The width of this Component. Should be only read.


x

public short x
The horizontal coordinate of this Component. Should be only read.


y

public short y
The vertical coordinate of this Component. Should be only read.


visible

public boolean visible
Is the Component visible ? Should be only read.


enabled

public boolean enabled
Is the Component enabled ? Should be only read.


mnemonic

public char mnemonic
The mnemonic associated with this component.


listen

public EventListener listen
The event listener for this component.

Constructor Detail

Component

public Component()
Constructs a newly allocated Component.

Method Detail

eventTriggered

public void eventTriggered(java.lang.Object sender)
Invoked when an event is triggered.

Parameters:
sender - The object who triggered the event.

finalize

public void finalize()
Free the memory and system ressources used by this Component.

Overrides:
finalize in class Object

onPaint

public void onPaint()
Called when a PaintEvent occurs to paint the image of the component and stores it in its virtual memory. A PaintEvent occurs when the aspect of the component is altered.


paint

public void paint()
This method is called to draw the component. Subclasses of Component are encouraged to overrides the paint method.


setBounds

public void setBounds(short x,
                      short y,
                      short width,
                      short height)

setX

public void setX(short x)

setY

public void setY(short y)

setWidth

public void setWidth(short width)

setHeight

public void setHeight(short height)

move

public void move(short x,
                 short y)

setVisible

public void setVisible(boolean b)
Sets the visibility of the component.

Parameters:
b - true if the component should be visible, false otherwize.

setEnabled

public void setEnabled(boolean b)
Sets if the component is enabled or not.

Parameters:
b - true if the component should be enabled, false otherwize.

setMnemonic

public void setMnemonic(char mnemonic)
Sets the mnemonic for this component.


use

public void use()
This method is invoked by the GEM when the user interacts with the component.


isCursorOver

public boolean isCursorOver(short x,
                            short y)
Indicates if the cursor is over this component.

Parameters:
x - the reference's horizontal coordinate
y - the reference's vertical coordinate
Returns:
true if the cursor is over the component, false otherwize.

center

public void center()

top

public void top()

bottom

public void bottom()

left

public void left()

right

public void right()

toFront

public Component toFront(Component c)
Called to brings a component to the front of a container.

Parameters:
c - the component to bring to front.
Returns:
this component if it is the component to bring to front, null otherwize.

clean

protected void clean()
Disposes of all ressources used by this component.


checkMnemonic

public void checkMnemonic(char m)
Checks if the mnemonic of this component correspond to the current mnemonic. If it is the case, an event is triggered.