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 Object

Component is the base class for VOLE user interface objects.

(c) Copyright 2003-2007 DOMOLOGIC GmbH


Field Summary
protected static java.util.Vector eventQueue
          Event queue for this component
protected static Component focusOwner
          Current focus owner (global flag)
protected  Resource font
          A font resource for drawing text.
protected  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(Resource font)
          Sets the font for this component.
 void setGraphics(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, getClass, notifyAll, toString, wait
 

Field Detail

x

protected int x
The control's x location


y

protected int y
The control's y location


width

protected int width
The control's width


height

protected int height
The control's height


parent

protected Container parent
The parent of the control.


g

protected Graphics g
The graphic context


visible

protected boolean visible
Our visibility


font

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


listener

protected ActionListener listener
ActionListener, called on ActionEvents


focusOwner

protected static Component focusOwner
Current focus owner (global flag)


eventQueue

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

Constructor Detail

Component

public Component()
Method Detail

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.

onActionEvent

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

Parameters:
e - the ActionEvent

getParent

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

Returns:
the parent container

setParent

public void setParent(Container parent)
Sets the parent Container

Parameters:
parent - the Container to be the parent Object

transferFocus

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

Returns:
true, if the focus was transferred successfully.

removeFocus

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


requestFocus

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


setGraphics

public void setGraphics(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

remove

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


paint

public void paint()
Paints this component.


setVisible

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

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

isVisible

public boolean isVisible()
Get visible state.

Returns:
boolean visible state

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

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}.

setFont

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

Parameters:
font - The new font.

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.