|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.ui.wombat.Component
public abstract class Component
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, labels and checkboxes etc of a typical graphical user interface.
The Component
class is the abstract superclass of all components in this library.
Class Component
may also be extended directly to create your own components.
To work properly, components must be part of a container-tree (see Container
), with a Frame instance
as top-level element.
There are two different types of components. Some components, such as labels or borders don't have any
interactive behaviour. Their only purpose is displaying text, images, measuring values or whatever. They
can neither be selected by any user action nor they can fire events.
Interactive components, such as buttons, combo boxes, list boxes, radio buttons etc, are controllable
by the user via keyboard and/or touch screen and they can even fire action events.
Note: It is not recommended to access components using multiple threads at the same time. This may cause synchronization problems resulting in unexpected behaviour.
Get more information and demo applications at www.jcontrol.org.(c) Copyright 2005-2007 DOMOLOGIC GmbH
Field Summary | |
---|---|
Color |
backgroundColor
|
static Color |
COLOR_COMPONENT_BACKGROUND
|
static Color |
COLOR_COMPONENT_BACKGROUND_HIGHLIGHTED
|
static Color |
COLOR_COMPONENT_DARK_SHADOW
|
static Color |
COLOR_COMPONENT_FOREGROUND
|
static Color |
COLOR_COMPONENT_FOREGROUND_INACTIVE
|
static Color |
COLOR_COMPONENT_HIGHLIGHT_SHADOW
|
static Color |
COLOR_COMPONENT_LIGHT_SHADOW
|
static Color |
COLOR_COMPONENT_LIST_BACKGROUND
|
static Color |
COLOR_COMPONENT_NORMAL_SHADOW
|
static Color |
COLOR_COMPONENT_SELECTION_TEXT
|
static Color |
COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND
|
static Color |
COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND_INACTIVE
|
static Color |
COLOR_COMPONENT_SELECTION_TEXT_INACTIVE
|
protected static Queue |
eventQueue
Static event queue for all components. |
protected Resource |
font
A font resource for drawing text. |
Color |
foregroundColor
|
IFrame |
frame
|
int |
height
The component's height. |
IContainer |
parent
The parent container of the component. |
protected static int |
RESERVED1
|
protected static int |
RESERVED2
|
protected static int |
RESERVED3
|
protected static int |
RESERVED4
|
protected static int |
RESERVED5
|
protected static int |
RESERVED6
|
int |
state
The state control flag. |
protected static int |
STATE_ABORT_UPDATE
|
protected static int |
STATE_ANIMATED
|
protected static int |
STATE_BG_COLOR_SET
|
protected static int |
STATE_COVERED
|
protected static int |
STATE_DIRTY_MASK
|
protected static int |
STATE_DIRTY_PAINTALL
|
protected static int |
STATE_DIRTY_REPAINT
|
protected static int |
STATE_DIRTY_UPDATE
|
protected static int |
STATE_DISABLED
|
protected static int |
STATE_DISPOSED
|
protected static int |
STATE_FG_COLOR_SET
|
protected static int |
STATE_FOCUS
|
protected static int |
STATE_HEIGHT_FIXED
|
protected static int |
STATE_NO_REDRAW
|
protected static int |
STATE_REVALIDATE
|
protected static int |
STATE_SELECTED
Selected state for buttons, comboboxes etc, |
protected static int |
STATE_SIZE_FIXED
|
protected static int |
STATE_UPDATED
If set, the last update has been accomplished successfully. |
protected static int |
STATE_VISIBLE
|
protected static int |
STATE_WIDTH_FIXED
|
Color |
transparentColor
|
int |
width
The component's width. |
int |
x
The component's x location. |
int |
y
The component's y location. |
Constructor Summary | |
---|---|
Component()
|
Method Summary | |
---|---|
protected void |
drawDisabledImage(XGraphics g,
Resource image,
int x,
int y,
int w,
int h)
|
IFrame |
getFrame()
Returns the applications root IFrame object. |
boolean |
isEnabled()
|
boolean |
isVisible()
Returns true if this component is set visible,
and false otherwise. |
protected boolean |
isVisibleInternal()
|
void |
paint(XGraphics g)
This method should not be called from the application. |
protected void |
redrawInternalAndParent()
Sets the repaint dirty flag for this component and all parent components. |
void |
repaint()
Causes the entire component to be marked as needing to be redrawn. |
void |
repaintAll()
Causes the entire component to be marked as needing to be redrawn. |
static void |
safeExec(Runnable runnable)
Causes the run() method of the runnable to
be invoked by the user-interface thread at the next
reasonable opportunity. |
void |
setBackgroundColor(Color background)
Sets the background color for this component. |
protected void |
setBackgroundColorInternal(Color background)
|
void |
setBounds(int x,
int y,
int width,
int height)
Set the dimensions of this component. |
void |
setDirty(int state,
boolean onoff)
This method should not be called from the application. |
void |
setEnabled(boolean enabled)
Sets the enabled state of this component. |
void |
setFont(Resource font)
Sets the font for this component. |
void |
setForegroundColor(Color foreground)
Sets the foreground color for this component. |
protected void |
setForegroundColorInternal(Color foreground)
|
protected void |
setParametersInternal(Resource font,
Color foregroundColor,
Color backgroundColor,
Color transparentColor)
|
void |
setRedraw(boolean onoff)
Disables/enables drawing for this component. |
void |
setTransparentColor(Color transparentColor)
Sets the transparent color for this component. |
void |
setVisible(boolean visible)
Turns the component visible or invisible. |
static void |
unsafeExec(Runnable runnable)
Causes the run() method of the runnable to
be invoked by the user-interface thread at the next
reasonable opportunity. |
void |
update(XGraphics g)
This method should not be called from the application. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notifyAll, toString, wait |
Field Detail |
---|
public static final Color COLOR_COMPONENT_FOREGROUND
public static final Color COLOR_COMPONENT_FOREGROUND_INACTIVE
public static final Color COLOR_COMPONENT_BACKGROUND
public static final Color COLOR_COMPONENT_BACKGROUND_HIGHLIGHTED
public static final Color COLOR_COMPONENT_DARK_SHADOW
public static final Color COLOR_COMPONENT_NORMAL_SHADOW
public static final Color COLOR_COMPONENT_LIGHT_SHADOW
public static final Color COLOR_COMPONENT_HIGHLIGHT_SHADOW
public static final Color COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND
public static final Color COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND_INACTIVE
public static final Color COLOR_COMPONENT_SELECTION_TEXT
public static final Color COLOR_COMPONENT_SELECTION_TEXT_INACTIVE
public static final Color COLOR_COMPONENT_LIST_BACKGROUND
protected static final int STATE_VISIBLE
protected static final int STATE_DIRTY_UPDATE
protected static final int STATE_DIRTY_REPAINT
protected static final int STATE_DIRTY_PAINTALL
protected static final int STATE_DIRTY_MASK
protected static final int STATE_ABORT_UPDATE
protected static final int STATE_ANIMATED
protected static final int STATE_UPDATED
protected static final int STATE_REVALIDATE
protected static final int STATE_WIDTH_FIXED
protected static final int STATE_HEIGHT_FIXED
protected static final int STATE_SIZE_FIXED
protected static final int STATE_COVERED
protected static final int STATE_DISPOSED
protected static final int STATE_FOCUS
protected static final int RESERVED1
protected static final int RESERVED2
protected static final int RESERVED3
protected static final int RESERVED4
protected static final int RESERVED5
protected static final int RESERVED6
protected static final int STATE_DISABLED
protected static final int STATE_NO_REDRAW
protected static final int STATE_FG_COLOR_SET
protected static final int STATE_BG_COLOR_SET
protected static final int STATE_SELECTED
public int x
setBounds(int, int, int, int)
public int y
setBounds(int, int, int, int)
public int width
setBounds(int, int, int, int)
public int height
setBounds(int, int, int, int)
public IContainer parent
public IFrame frame
public int state
protected Resource font
public Color foregroundColor
public Color backgroundColor
public Color transparentColor
protected static Queue eventQueue
Constructor Detail |
---|
public Component()
Method Detail |
---|
public void setRedraw(boolean onoff)
onoff
- true - drawing on (default), false - drawing offpublic static void safeExec(Runnable runnable)
run()
method of the runnable to
be invoked by the user-interface thread at the next
reasonable opportunity. The thread calling this method
is blocked until the runnable has been completed.
This method should be used every time when the ui framework is modified from a thread
that is NOT the user interface thread. Please use this method only after the
method setVisible(true)
of the main frame has been called
(because this mthod is starting the user-interface thread).
When an application adds or removes components or when it changes the content of the main
frame, it is strongly recommended to use safeExec(). Otherwise, the ui framework
might behave unexpectedly.
Use the method safeExec() as shown by the following code snipped:
// The run method of any thread
public void run() {
...
// here, the content of the main frame should be changed
// call the safeExec method
Component.safeExec(new Runnable() {
public void run() {
// place your code here to be executed by the ui-thread
// example:
frame.setContent(new MyContent());
}
});
// here, the content of the frame has already been changed because
// this thread was blocked until the runnable has been executed
...
}
runnable
- the runnable to executeunsafeExec(Runnable)
public static void unsafeExec(Runnable runnable)
run()
method of the runnable to
be invoked by the user-interface thread at the next
reasonable opportunity. The caller of this method continues
to run in parallel, and is not notified when the
runnable has been completed.
This method should be used every time when the ui framework is modified from a thread
that is NOT the user interface thread. Please use this method only after the
method setVisible(true)
of the main frame has been called
(because this mthod is starting the user-interface thread).
When an application adds or removes components or when it changes the content of the main
frame, it is strongly recommended to use safeExec(). Otherwise, the ui framework
might behave unexpectedly.
Use the method unsafeExec() as shown by the following code snipped:
// The run method of any thread
public void run() {
...
// here, the content of the main frame should be changed
// call the unsafeExec method
Component.unsafeExec(new Runnable() {
public void run() {
// place your code here to be executed by the ui-thread
// example:
frame.setContent(new MyContent());
}
});
// here, the content of the frame has NOT been changed yet and
// this thread continues to run BEFORE the runnable has been executed
...
}
runnable
- the runnable to executesafeExec(Runnable)
public IFrame getFrame()
public void update(XGraphics g)
g
- the application's graphics object.protected void setForegroundColorInternal(Color foreground)
protected void setBackgroundColorInternal(Color background)
protected void setParametersInternal(Resource font, Color foregroundColor, Color backgroundColor, Color transparentColor)
public void setTransparentColor(Color transparentColor)
transparentColor
- the transparent color to setpublic void setForegroundColor(Color foreground)
foreground
- the foreground color to setpublic void setBackgroundColor(Color background)
background
- the background color to setprotected void redrawInternalAndParent()
public void paint(XGraphics g)
g
- the application's graphics object.public void setDirty(int state, boolean onoff)
state
-parameter. All parent containers are set/unset dirty.
state
- the state to setonoff
- set or unset the statepublic void repaint()
public void repaintAll()
public void setVisible(boolean visible)
visible
- the visible state to set.public void setEnabled(boolean enabled)
enabled
- the enabled state.public boolean isEnabled()
public boolean isVisible()
Returns true
if this component is set visible,
and false
otherwise.
protected boolean isVisibleInternal()
public void setBounds(int x, int y, int width, int height)
x
- The x-coordinate of the upper left cornery
- The y-coordinate of the upper left cornerwidth
- The width of this componentheight
- The height of this componentpublic void setFont(Resource font)
font
- the new font.protected void drawDisabledImage(XGraphics g, Resource image, int x, int y, int w, int h)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |