org.zaval.lw
Class J2SEDesktop
java.lang.Object
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.LwPanel
|
+--org.zaval.lw.J2SEDesktop
- All Implemented Interfaces:
- java.util.EventListener, java.awt.event.KeyListener, Layoutable, LayoutContainer, LwComponent, LwContainer, LwDesktop, LwLayout, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, Validationable
- public class J2SEDesktop
- extends LwPanel
- implements LwDesktop, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, LwLayout
This is J2SE light weight desktop implementation that allows you to have the light weight
components for J2SE or J2ME Personal Profile applications. The class supplies the
following functionality:
-
Gets Java AWT events and transforms its to the light weight events.
-
Provides graphical surface to paint the light weight components hierarchy.
-
Supports desktop layers.
-
Provides custom properties support. For example, the implementation supports
mouse cursor type property. Use the
getProperty and the setProperty
methods to control the property.
You should not use or create the class manually. The library provides LwFrame and LwApplet
classes to create own applications and applets. The classes hide native specific and we
strongly recommend use only these classes as follow:
// Light weight application
...
LwFrame frame = LwFrame();
LwContainer root = frame.getRoot();
root.setLwLayout(new LwBorderLayout());
LwButton button = new LwButton("Ok");
root.add(LwBorderLayout.CENTER, button);
frame.setSize(400, 400);
frame.setVisible(true);
...
or the same for applets:
// Light weight applet
...
public class YourApplet
extends LwApplet
{
public void init ()
{
super.init();
LwContainer root = this.getRoot();
root.setLwLayout(new LwBorderLayout());
LwButton button = new LwButton("Ok");
root.add(LwBorderLayout.CENTER, button);
...
}
...
}
| Fields inherited from class org.zaval.lw.LwCanvas |
bits, bottom, height, isValidValue, left, parent, psHeight, psWidth, right, skins, temporary, top, width, x, y |
|
Method Summary |
void |
activate(boolean b)
Invoked whenever the desktop has been activated or de-activated. |
java.awt.Dimension |
calcPreferredSize(LayoutContainer target)
Calculates the preferred size dimension for the layout container.
|
void |
componentAdded(java.lang.Object id,
Layoutable lw,
int index)
Invoked when the specified layoutable component was added to the layout container
(that uses the layout manager). |
void |
componentRemoved(Layoutable lw,
int index)
Invoked when the specified layoutable component was removed from the layout
container, that uses the layout manager. |
java.awt.Image |
createImage(int w,
int h)
Creates an off-screen image to be used for double buffering with the specified width
and height. |
java.awt.Rectangle |
getDA()
Gets the dirty area of the component. |
protected LwLayout |
getDefaultLayout()
Gets the default layout manager that is set with the container during initialization.
|
java.awt.Graphics |
getGraphics()
Gets a graphics context for this desktop. |
LwLayer |
getLayer(java.lang.Object id)
Gets the layer by the specified id. |
LwComponent |
getLwComponentAt(int x,
int y)
Determines if the component or an immediate child component contains the
(x, y) location in its visible part and if so, returns the component. |
java.lang.Object |
getNCanvas()
Gets the native component where the desktop layer "lives". |
java.lang.Object |
getProperty(int id)
Gets the value for the specified property. |
LwLayer |
getRootLayer()
Gets the root layer that should be used to add a light weight component on the desktop
surface. |
void |
keyPressed(java.awt.event.KeyEvent e)
Invoked when a key has been pressed. |
void |
keyReleased(java.awt.event.KeyEvent e)
Invoked when a key has been released. |
void |
keyTyped(java.awt.event.KeyEvent e)
Invoked when a key has been typed.
|
void |
layout(LayoutContainer target)
Lays out the child layoutable components inside the layout container. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then
dragged. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component. |
void |
mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component
(with no buttons no down). |
void |
mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component. |
void |
repaint()
Performs repainting process of this component. |
void |
repaint(int x,
int y,
int w,
int h)
Performs repainting process of the specified rectangular area of this component. |
void |
setProperty(int id,
java.lang.Object value)
Sets the value for the specified property. |
| Methods inherited from class org.zaval.lw.LwPanel |
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwLayout, getPreferredSize, indexOf, insert, insert, invalidate, isInvalidatedByChild, laidout, paintOnTop, remove, remove, removeAll, setBackground, setLwLayout, setOpaque, setSize, toFront, updateCashedPs, validate |
| Methods inherited from class org.zaval.lw.LwCanvas |
calcInsets, canHaveFocus, customize, cvp, getBackground, getBottom, getBounds, getHeight, getInsets, getLeft, getLocation, getLwParent, getOrigin, getPSImpl, getRight, getSize, getTop, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isValid, isVisible, paint, recalc, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setViewMan, setVisible, update, viewManChanged, vrp |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.zaval.lw.LwComponent |
canHaveFocus, getBackground, getLwParent, getOrigin, getViewMan, getVisiblePart, isEnabled, isOpaque, paint, repaint, setBackground, setEnabled, setInsets, setLwParent, setOpaque, setViewMan, setVisible, update |
| Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize |
CURSOR_PROPERTY
public static final int CURSOR_PROPERTY
- Defines cursor property id. The id should be used as the property name argument for
getProperty and setProperty methods to control
native cursor state.
getNCanvas
public java.lang.Object getNCanvas()
- Description copied from interface:
LwDesktop
- Gets the native component where the desktop layer "lives". For example, in a case the
J2SE LwVCL version the method returns a java.awt.Panel instance as the native component.
- Specified by:
getNCanvas in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Returns:
- a native component.
getLwComponentAt
public LwComponent getLwComponentAt(int x,
int y)
- Description copied from interface:
LwComponent
- Determines if the component or an immediate child component contains the
(x, y) location in its visible part and if so, returns the component.
- Specified by:
getLwComponentAt in interface LwComponent- Overrides:
getLwComponentAt in class LwPanel
- Following copied from interface:
org.zaval.lw.LwComponent
- Parameters:
x - the x coordinate.y - the y coordinate.- Returns:
- the component or subcomponent that contains the (x, y) location;
null if the location is outside this component.
getRootLayer
public LwLayer getRootLayer()
- Description copied from interface:
LwDesktop
- Gets the root layer that should be used to add a light weight component on the desktop
surface.
- Specified by:
getRootLayer in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Returns:
- a root layer.
getLayer
public LwLayer getLayer(java.lang.Object id)
- Description copied from interface:
LwDesktop
- Gets the layer by the specified id. There are two layers available by the "root" and "win" IDs.
- Specified by:
getLayer in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Parameters:
id - the specified id.- Returns:
- a layer.
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Invoked when the mouse has been clicked on a component.
- Specified by:
mouseClicked in interface java.awt.event.MouseListener
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Invoked when the mouse enters a component.
- Specified by:
mouseEntered in interface java.awt.event.MouseListener
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Invoked when the mouse exits a component.
- Specified by:
mouseExited in interface java.awt.event.MouseListener
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Invoked when a mouse button has been pressed on a component.
- Specified by:
mousePressed in interface java.awt.event.MouseListener
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Invoked when a mouse button has been released on a component.
- Specified by:
mouseReleased in interface java.awt.event.MouseListener
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- Invoked when a key has been pressed.
- Specified by:
keyPressed in interface java.awt.event.KeyListener
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Invoked when a key has been released.
- Specified by:
keyReleased in interface java.awt.event.KeyListener
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Invoked when a key has been typed.
This event occurs when a key press is followed by a key release.
- Specified by:
keyTyped in interface java.awt.event.KeyListener
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Invoked when the mouse button has been moved on a component
(with no buttons no down).
- Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Invoked when a mouse button is pressed on a component and then
dragged. Mouse drag events will continue to be delivered to
the component where the first originated until the mouse button is
released (regardless of whether the mouse position is within the
bounds of the component).
- Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
componentAdded
public void componentAdded(java.lang.Object id,
Layoutable lw,
int index)
- Description copied from interface:
LwLayout
- Invoked when the specified layoutable component was added to the layout container
(that uses the layout manager). The specified constraints, layoutable component
and child index are passed as arguments into the method.
- Specified by:
componentAdded in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
id - the layoutable component constraints.lw - the layoutable component that has been added.index - the child index.
componentRemoved
public void componentRemoved(Layoutable lw,
int index)
- Description copied from interface:
LwLayout
- Invoked when the specified layoutable component was removed from the layout
container, that uses the layout manager.
- Specified by:
componentRemoved in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
lw - the layoutable component that has been removed.index - the child component index.
calcPreferredSize
public java.awt.Dimension calcPreferredSize(LayoutContainer target)
- Description copied from interface:
LwLayout
- Calculates the preferred size dimension for the layout container.
The method has to calculate "pure" preferred size, it means that container insets
should not be taken into account.
- Specified by:
calcPreferredSize in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
target - the layout container.- Returns:
- a "pure" preferred size.
layout
public void layout(LayoutContainer target)
- Description copied from interface:
LwLayout
- Lays out the child layoutable components inside the layout container.
- Specified by:
layout in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
target - the layout container.
getProperty
public java.lang.Object getProperty(int id)
- Description copied from interface:
LwDesktop
- Gets the value for the specified property.
- Specified by:
getProperty in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Parameters:
id - the specified property id.- Returns:
- a value of the property.
setProperty
public void setProperty(int id,
java.lang.Object value)
- Description copied from interface:
LwDesktop
- Sets the value for the specified property.
- Specified by:
setProperty in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Parameters:
id - the specified property id.value - the specified property value.
getGraphics
public java.awt.Graphics getGraphics()
- Description copied from interface:
LwDesktop
- Gets a graphics context for this desktop. This is adaptive method and it is used to bind
native GUI implementation with the components of the library.
- Specified by:
getGraphics in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Returns:
- a graphics context.
createImage
public java.awt.Image createImage(int w,
int h)
- Description copied from interface:
LwDesktop
- Creates an off-screen image to be used for double buffering with the specified width
and height. This is adaptive method and it is used to bind native GUI implementation with the
components of the library.
- Specified by:
createImage in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Parameters:
w - the specified image width.h - the specified image height.- Returns:
- an off-screen image.
activate
public void activate(boolean b)
- Description copied from interface:
LwDesktop
- Invoked whenever the desktop has been activated or de-activated.
- Specified by:
activate in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Parameters:
b - the flag specifies if the desktop has been activated or de-activated.
The argument value is true if the desktop has been activated.
repaint
public void repaint()
- Description copied from interface:
LwComponent
- Performs repainting process of this component. The method causes
calling of
update and than paint methods.
- Specified by:
repaint in interface LwComponent- Overrides:
repaint in class LwCanvas
repaint
public void repaint(int x,
int y,
int w,
int h)
- Description copied from interface:
LwComponent
- Performs repainting process of the specified rectangular area of this component. The method causes
calling of
update and than paint methods.
- Specified by:
repaint in interface LwComponent- Overrides:
repaint in class LwCanvas
- Following copied from interface:
org.zaval.lw.LwComponent
- Parameters:
x - the x coordinate.y - the y coordinate.w - the width.h - the height.
getDefaultLayout
protected LwLayout getDefaultLayout()
- Description copied from class:
LwPanel
- Gets the default layout manager that is set with the container during initialization.
This implementation of the method returns LwRastLayout as the default layout manager, the
layout manager is got as a static object by "def.lay" key.
- Overrides:
getDefaultLayout in class LwPanel
- Following copied from class:
org.zaval.lw.LwPanel
- Returns:
- a layout manager.
getDA
public java.awt.Rectangle getDA()
- Description copied from interface:
LwDesktop
- Gets the dirty area of the component. The method is used to store and update
the desktop dirty area (this is the area that should be updated).
- Specified by:
getDA in interface LwDesktop
- Following copied from interface:
org.zaval.lw.LwDesktop
- Returns:
- a dirty area.
|