|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--org.zaval.lw.LwRoot
This class is a root light weight component that implements LwDesktop interface. The main purpose of the class to provide connection between native Java AWT library implementation and light weight components hierarchy. So, on the one hand the class is light weight components (implements LwContainer interface) and on the other hand this class inherits Java AWT component (java.awt.Panel). Using the class the light weight library:
getProperty
and setProperty
methods to control the property.
... LwContainer root = new LwRoot(); root.getRootLayer().setLwLayout(new LwBorderLayout()); LwButton button = new LwButton("Ok"); root.getRootLayer().add(LwBorderLayout.CENTER, button); ... java.awt.Frame frame = java.awt.Frame(); frame.setSize(400, 400); frame.setLayout(new BorderLayout()); frame.add("Center", root); frame.setVisible(true); ... OR ... Applet applet = new Applet(); applet.setLayout(new BorderLayout()); applet.add("Center", root); ...First of all the sample above uses the root layer component as a light weight container for creating the light weight hierarchy. The second part shows the usage of the root as a part of Java AWT frame component and a java applet.
More easy way is using of LwFrame class that inherits java.awt.Frame and provides the lightweight top-level container ready to create lightweight hierarchy:
... 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); ...
Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
static int |
CURSOR_PROPERTY
Defines cursor property id. |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
LwRoot()
Constructs the class instance. |
Method Summary | |
void |
add(LwComponent c)
Adds the specified lightweight component as a child of this container. |
void |
add(java.lang.Object s,
LwComponent c)
Adds the specified lightweight component with the specified constraints as a child of this container. |
java.awt.Dimension |
calcPreferredSize(LayoutContainer target)
Calculates the preferred size dimension for the layout container. |
boolean |
canHaveFocus()
Specifies if the component can have focus. |
void |
componentAdded(java.lang.Object id,
Layoutable lw,
int index)
Invoked when the specified layoutable component is added to the layout container (that uses the layout manager). |
void |
componentHidden(java.awt.event.ComponentEvent e)
Invoked when component has been hidden. |
void |
componentMoved(java.awt.event.ComponentEvent e)
Invoked when component has been moved. |
void |
componentRemoved(Layoutable lw,
int index)
Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager. |
void |
componentResized(java.awt.event.ComponentEvent e)
Invoked when component has been resized. |
void |
componentShown(java.awt.event.ComponentEvent e)
Invoked when component has been shown. |
int |
count()
Returns the number of child elements in this container. |
void |
focusGained(java.awt.event.FocusEvent e)
Invoked when a component gains the keyboard focus. |
void |
focusLost(java.awt.event.FocusEvent e)
Invoked when a component loses the keyboard focus. |
Layoutable |
get(int index)
Gets a child element at the given index. |
int |
getHeight()
Gets the height of this component. |
java.awt.Insets |
getInsets()
Determines the insets of this component. |
LwLayer |
getLayer(java.lang.Object id)
Gets the layer by the specified id. |
java.lang.Object[] |
getLayersIDs()
Gets the list of available layers' IDs. |
java.awt.Point |
getLayoutOffset()
Returns the offset. |
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. |
LwLayout |
getLwLayout()
Gets a layout manager for this container. |
LwComponent |
getLwParent()
Gets the lightweight parent of this component. |
java.awt.Point |
getOrigin()
Returns an origin of the drawable component. |
java.awt.Dimension |
getPreferredSize()
Gets the preferred size of this component. |
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. |
LwViewMan |
getViewMan(boolean b)
Returns a view manager of the component. |
java.awt.Rectangle |
getVisiblePart()
Returns the bounding rectangle of the visible part for the component. |
int |
getWidth()
Gets the width of this component. |
int |
getX()
Gets the x location of this component specifying the component top-left corner. |
int |
getY()
Gets the y location of this component specifying the component top-left corner. |
int |
indexOf(LwComponent c)
Searches the specified component among this container children and returns an index of the component in the child list. |
void |
insert(int i,
java.lang.Object s,
LwComponent d)
Inserts the specified lightweight component with the specified constraints as a child of this container at the specified position in the container list. |
boolean |
isFocusTraversable()
Returns whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal. |
boolean |
isOpaque()
Gets the opaque of this component. |
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 |
paint(java.awt.Graphics g)
Paints this drawable component. |
void |
paintOnTop(java.awt.Graphics g)
Paints additional elements (for example, marker) after the container and its child components have been rendered. |
void |
remove(int i)
Removes the component, specified by the index, from this container. |
void |
removeAll()
Removes all child components from this container. |
void |
reshape(int x,
int y,
int w,
int h)
|
void |
setEnabled(boolean b)
Enables or disables this component. |
void |
setLwLayout(LwLayout l)
Sets the layout manager for this container. |
void |
setLwParent(LwComponent p)
Sets the lightweight parent of this component. |
void |
setOpaque(boolean b)
Sets the opaque of this component. |
void |
setProperty(int id,
java.lang.Object value)
Sets the value for the specified property. |
void |
setViewMan(LwViewMan v)
Sets the specified view manager for the component. |
void |
update(java.awt.Graphics g)
Updates this drawable component. |
void |
validate()
Validates this object. |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, removeNotify, setFont, setLayout, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.zaval.lw.LwDesktop |
createImage, getGraphics |
Methods inherited from interface org.zaval.lw.LwComponent |
setBackground, setVisible |
Methods inherited from interface org.zaval.lw.Drawable |
getBackground, isEnabled, repaint, repaint |
Methods inherited from interface org.zaval.util.Validationable |
invalidate, isValid |
Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getLocation, getSize, isVisible, setLocation, setSize |
Field Detail |
public static final int CURSOR_PROPERTY
getProperty
and setProperty
method to control
native cursor state.Constructor Detail |
public LwRoot()
Method Detail |
public void setLwLayout(LwLayout l)
LwContainer
setLwLayout
in interface LwContainer
org.zaval.lw.LwContainer
m
- the specified layout manager.public int getX()
Layoutable
x
location of this component specifying the component top-left corner.
The location is relative to the parent component coordinate space.getX
in interface Layoutable
getX
in class java.awt.Component
org.zaval.lw.Layoutable
x
coordinate representing the top-left corner
of the component bounds in the coordinate space of the component parent.public int getY()
Layoutable
y
location of this component specifying the component top-left corner.
The location is relative to the parent component coordinate space.getY
in interface Layoutable
getY
in class java.awt.Component
org.zaval.lw.Layoutable
y
coordinate representing the top-left corner
of the component bounds in the coordinate space of the component parent.public int getWidth()
Layoutable
getWidth
in interface Layoutable
getWidth
in class java.awt.Component
org.zaval.lw.Layoutable
public int getHeight()
Layoutable
getHeight
in interface Layoutable
getHeight
in class java.awt.Component
org.zaval.lw.Layoutable
public LwLayout getLwLayout()
LwContainer
getLwLayout
in interface LwContainer
org.zaval.lw.LwContainer
public LwComponent getLwParent()
null
, since the root component cannot have
a light weight component as a parent, because this component should be used as
a top-level light weight component.getLwParent
in interface LwComponent
null
.public void setLwParent(LwComponent p)
RuntimeException
if you try to call it.setLwParent
in interface LwComponent
p
- the parent component of this lightweight component.public LwViewMan getViewMan(boolean b)
LwComponent
null
.
The input argument autoCreate
defines if the view manager has to be created
automatically in a case if it has not been determined before. It means, if the argument is
true
and the view manager is null
, than the component will
try to create and initialize its view manager by a default view manager. If the argument
is false
than the method returns the component view manager as is.getViewMan
in interface LwComponent
org.zaval.lw.LwComponent
autoCreate
- the flag defines if the view manager should be created
automatically.public void setViewMan(LwViewMan v)
LwComponent
setViewMan
in interface LwComponent
org.zaval.lw.LwComponent
man
- the view manager to set for the component.public java.awt.Rectangle getVisiblePart()
LwComponent
getVisiblePart
in interface LwComponent
org.zaval.lw.LwComponent
public LwComponent getLwComponentAt(int x, int y)
LwComponent
getLwComponentAt
in interface LwComponent
org.zaval.lw.LwComponent
x
- the x coordinate.y
- the y coordinate.null
if the location is outside this component.public boolean isOpaque()
false
than the component is transparent, in this case
update
method has not be called during painting process.
The method allways returns true
as result, because this is
root component.isOpaque
in interface Drawable
isOpaque
in class java.awt.Component
true
if the component is opaque; otherwise
false
.public Layoutable get(int index)
LayoutContainer
get
in interface LayoutContainer
org.zaval.lw.LayoutContainer
index
- the index of a child to be returned.public int count()
LayoutContainer
count
in interface LayoutContainer
org.zaval.lw.LayoutContainer
public void add(LwComponent c)
LwContainer
componentAdded
method its layout manager to inform
the layout manager that the new child has been added.add
in interface LwContainer
org.zaval.lw.LwContainer
c
- the lightweight component to be added.public void add(java.lang.Object s, LwComponent c)
LwContainer
componentAdded
method its
layout manager to inform the layout manager that the new child has been added.add
in interface LwContainer
org.zaval.lw.LwContainer
s
- the object expressing layout contraints for this.c
- the lightweight component to be added.public void insert(int i, java.lang.Object s, LwComponent d)
LwContainer
componentAdded
method its layout manager to inform the layout manager
that the new child has been added with the given constraints.insert
in interface LwContainer
org.zaval.lw.LwContainer
i
- the position in the container list at which to insert
the component.s
- the object expressing layout contraints for this.c
- the lightweight component to be added.public void remove(int i)
LwContainer
componentRemoved
method of the manager.remove
in interface LwContainer
remove
in class java.awt.Container
org.zaval.lw.LwContainer
index
- the index of the component to be removed.public void removeAll()
LwContainer
componentRemoved
method of the manager for every child component
that has been removed.removeAll
in interface LwContainer
removeAll
in class java.awt.Container
public int indexOf(LwComponent c)
LwContainer
-1
.indexOf
in interface LwContainer
org.zaval.lw.LwContainer
c
- the component to get index.public void validate()
Validationable
validate
in interface Validationable
validate
in class java.awt.Container
public void setEnabled(boolean b)
LwComponent
setEnabled
in interface LwComponent
setEnabled
in class java.awt.Component
org.zaval.lw.LwComponent
b
- if the value is true
- enables the component;
otherwise disables this component.public java.awt.Dimension getPreferredSize()
Layoutable
getPreferredSize
in interface Layoutable
getPreferredSize
in class java.awt.Container
org.zaval.lw.Layoutable
public java.awt.Insets getInsets()
Layoutable
getInsets
in interface Layoutable
getInsets
in class java.awt.Container
org.zaval.lw.Layoutable
public void update(java.awt.Graphics g)
Drawable
paint
method and it is performed with
repaint
method. The method can be used to fill the drawable
component with the background color if the component is opaque.update
in interface Drawable
update
in class java.awt.Container
org.zaval.lw.Drawable
g
- the specified context to be used for updating.public void paint(java.awt.Graphics g)
Drawable
paint
in interface Drawable
paint
in class java.awt.Container
org.zaval.lw.Drawable
g
- the graphics context to be used for painting.public void paintOnTop(java.awt.Graphics g)
LwContainer
paintOnTop
in interface LwContainer
org.zaval.lw.LwContainer
g
-
the graphics context.public LwLayer getRootLayer()
LwDesktop
getRootLayer
in interface LwDesktop
org.zaval.lw.LwDesktop
public LwLayer getLayer(java.lang.Object id)
LwDesktop
getLayer
in interface LwDesktop
org.zaval.lw.LwDesktop
id
- by the specified id.public java.lang.Object[] getLayersIDs()
LwDesktop
getLayersIDs
in interface LwDesktop
org.zaval.lw.LwDesktop
public void componentHidden(java.awt.event.ComponentEvent e)
componentHidden
in interface java.awt.event.ComponentListener
public void componentMoved(java.awt.event.ComponentEvent e)
componentMoved
in interface java.awt.event.ComponentListener
public void reshape(int x, int y, int w, int h)
reshape
in class java.awt.Component
public void componentResized(java.awt.event.ComponentEvent e)
componentResized
in interface java.awt.event.ComponentListener
public void componentShown(java.awt.event.ComponentEvent e)
componentShown
in interface java.awt.event.ComponentListener
public boolean isFocusTraversable()
isFocusTraversable
in class java.awt.Component
public void setOpaque(boolean b)
false
argument value to make a transparent component from this component.
The method usage has not any effect, because the root component has to
be always opaque.setOpaque
in interface Drawable
b
- the opaque flag.public java.awt.Point getOrigin()
Drawable
getOrigin
in interface Drawable
org.zaval.lw.Drawable
public java.awt.Point getLayoutOffset()
LayoutContainer
x
is offset for x-coordinates and y
is offset for y-coordinates. The ability to offset child components with a layout manager
is used with the library to organize scrolling.getLayoutOffset
in interface LayoutContainer
org.zaval.lw.LayoutContainer
public void focusGained(java.awt.event.FocusEvent e)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent e)
focusLost
in interface java.awt.event.FocusListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void componentAdded(java.lang.Object id, Layoutable lw, int index)
LwLayout
componentAdded
in interface LwLayout
org.zaval.lw.LwLayout
id
- the layoutable component constraints.lw
- the layoutable component that has been added.index
- the child index.public void componentRemoved(Layoutable lw, int index)
LwLayout
componentRemoved
in interface LwLayout
org.zaval.lw.LwLayout
lw
- the layoutable component that has been removed.index
- the child component index.public java.awt.Dimension calcPreferredSize(LayoutContainer target)
LwLayout
calcPreferredSize
in interface LwLayout
org.zaval.lw.LwLayout
target
- the layout container.public void layout(LayoutContainer target)
LwLayout
layout
in interface LwLayout
org.zaval.lw.LwLayout
target
- the layout container that needs to be laid out.public java.lang.Object getProperty(int id)
LwDesktop
getProperty
in interface LwDesktop
org.zaval.lw.LwDesktop
id
- the specified property id.public void setProperty(int id, java.lang.Object value)
LwDesktop
setProperty
in interface LwDesktop
org.zaval.lw.LwDesktop
id
- the specified property id.value
- the specified property value.public boolean canHaveFocus()
LwComponent
canHaveFocus
in interface LwComponent
org.zaval.lw.LwComponent
true
if the component can have the focus.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |