jcontrol.ui.vole
Class Component

java.lang.Object
  extended by jcontrol.ui.vole.Component
Direct Known Subclasses:
AnalogClock, AnalogMeter, BarMeter, Border, Button, CheckBox, ComboBox, Container, Diagram, DigitalMeter, FanMeter, Histogram, Label, List, Menu, NumberChooser, RadioButton, RockerSwitch, ScrollBar, SevenSegmentMeter, Slider, TextArea, TextScroller, Thermometer

public abstract class Component
extends java.lang.Object

Component is the base class for VOLE user interface objects.

(c) Copyright 2003-2007 DOMOLOGIC GmbH

Version:
1.0
Author:
Marcus Timmermann, Wolfgang Klingauf

Field Summary
protected static java.util.Vector eventQueue
          Event queue for this component
protected static Component focusOwner
          Current focus owner (global flag)
protected  jcontrol.io.Resource font
          A font resource for drawing text.
protected  jcontrol.io.Graphics g
          The graphic context
protected  int height
          The control's height
protected  ActionListener listener
          ActionListener, called on ActionEvents
protected  Container parent
          The parent of the control.
protected  boolean visible
          Our visibility
protected  int width
          The control's width
protected  int x
          The control's x location
protected  int y
          The control's y location
 
Constructor Summary
Component()
           
 
Method Summary
 int[] getBounds()
          Returns the current bounds of this component as array of int.
 Container getParent()
          Return the parent container if available.
 boolean isVisible()
          Get visible state.
 void onActionEvent(ActionEvent e)
          ActionEvent event handler.
 boolean onKeyEvent(KeyEvent e)
          Keyboard event handler.
 void paint()
          Paints this component.
 void remove()
          Removes this component and draws a rectangle in the background color.
 void removeFocus()
          Removes the focus from this Component.
 void requestFocus()
          Sets the focus to this Component.
 void setBounds(int x, int y, int width, int height)
          Set the dimensions of this component.
 void setFont(jcontrol.io.Resource font)
          Sets the font for this component.
 void setGraphics(jcontrol.io.Graphics g)
          This method is called to set the main Display context for this component.
 void setParent(Container parent)
          Sets the parent Container
 void setVisible(boolean visible)
          Turns the component visible or invisible.
 boolean transferFocus()
          Transfers the focus to the next component.
 void validate()
          Calculate and set the preferred size of this Component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, notifyAll, wait
 

Field Detail

eventQueue

protected static java.util.Vector eventQueue
Event queue for this component


focusOwner

protected static Component focusOwner
Current focus owner (global flag)


font

protected jcontrol.io.Resource font
A font resource for drawing text. Components are self-responsible for making use of this resource.


g

protected jcontrol.io.Graphics g
The graphic context


height

protected int height
The control's height


listener

protected ActionListener listener
ActionListener, called on ActionEvents


parent

protected Container parent
The parent of the control.


visible

protected boolean visible
Our visibility


width

protected int width
The control's width


x

protected int x
The control's x location


y

protected int y
The control's y location

Constructor Detail

Component

public Component()
Method Detail

getBounds

public int[] getBounds()
Returns the current bounds of this component as array of int.

Returns:
int[] The bounds of this component, ordered {x, y, width, height}.

getParent

public Container getParent()
Return the parent container if available.

Returns:
the parent container

isVisible

public boolean isVisible()
Get visible state.

Returns:
boolean visible state

onActionEvent

public void onActionEvent(ActionEvent e)
ActionEvent event handler. Overwrite this method if you want to receive ActionEvents.

Parameters:
e - the ActionEvent

onKeyEvent

public boolean onKeyEvent(KeyEvent e)
Keyboard event handler. Overwrite this method if you want to receive key events.

Parameters:
e - the KeyEvent
Returns:
If this method returns true, the KeyEvent is handled by the super Container.

paint

public void paint()
Paints this component.


remove

public void remove()
Removes this component and draws a rectangle in the background color.


removeFocus

public void removeFocus()
Removes the focus from this Component.


requestFocus

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


setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Set the dimensions of this component. The component is repainted automatically.

Parameters:
x - x coordinate of the upper left corner
y - y coordinate of the upper left corner
width - The width of this component
height - The height of this component

setFont

public void setFont(jcontrol.io.Resource font)
Sets the font for this component.

Parameters:
font - The new font.

setGraphics

public void setGraphics(jcontrol.io.Graphics g)
This method is called to set the main Display context for this component. Normally, this is done only for the top-level container, then, all child components are set automatically.

Parameters:
g - the Display

setParent

public void setParent(Container parent)
Sets the parent Container

Parameters:
parent - the Container to be the parent Object

setVisible

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

Parameters:
onoff - true, if visible - false, otherwise

transferFocus

public boolean transferFocus()
Transfers the focus to the next component.

Returns:
true, if the focus was transferred successfully.

validate

public void validate()
Calculate and set the preferred size of this Component. The calculated values depend on various parameters like font size and drawing styles. After calculation, the component's paint- method should be invoked.