org.zaval.lw
Class LwPanel
java.lang.Object
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.LwPanel
- All Implemented Interfaces:
- Layoutable, LayoutContainer, LwComponent, LwContainer, Validationable
- Direct Known Subclasses:
- J2SEDesktop, LwActContainer, LwAList, LwBaseLayer, LwBorderPan, LwColorPanel, LwCombo, LwExtender, LwFilePanel, LwFontPanel, LwGrid, LwMenuBar, LwNotebook, LwScroll, LwScrollPan, LwSpin, LwSplitPan, LwStatusBar, LwTree, LwWindow
- public class LwPanel
- extends LwCanvas
- implements LwContainer
This is implementation of the light weight container interface that has to be used
to develop own light weight containers. The container implementation inherits
the light weight component implementation. Draw attention at the following features:
-
The implementation uses a layout manager to layout child components. The layout
manager cannot be
null.
-
You can define a preferred size for the container by
calcPreferredSize method as it needs for LwCanvas.
By default container calculates its preferred size by a layout manager.
-
You can override
recalc method to calculate the container metrical characteristics
that have an influence on the container preferred size.
-
This implementation of the container uses LwRasterLayout as default layout manager.
The layout manager uses original sizes and locations (that have been set by
setSize and setLocation methods of the components)
to layout child components.
|
Field Summary |
protected java.util.Vector |
children
|
| Fields inherited from class org.zaval.lw.LwCanvas |
bits, bottom, height, isValidValue, left, parent, psHeight, psWidth, right, skins, temporary, top, width, x, y |
|
Constructor Summary |
LwPanel()
Constructs the container. |
|
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. |
protected java.awt.Dimension |
calcPreferredSize()
Gets the "pure" preferred size for this component. |
int |
count()
Returns the number of child components in this container. |
Layoutable |
get(int i)
Gets a child component at the given index. |
protected LwLayout |
getDefaultLayout()
Gets the default layout manager that is set with the container during initialization.
|
java.awt.Point |
getLayoutOffset()
Returns the offset. |
LwComponent |
getLwComponentAt(int xx,
int yy)
Determines if the component or an immediate child component contains the
(xx, yy) location in its visible part and if so, returns the component. |
LwLayout |
getLwLayout()
Gets the layout manager of this container. |
java.awt.Dimension |
getPreferredSize()
Gets the preferred size of this component. |
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,
LwComponent d)
Inserts the specified lightweight component as a child of this container
at the specified position in the container 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. |
void |
invalidate()
Invalidates this object. |
boolean |
isInvalidatedByChild(LwComponent c)
Invoked by a child component whenever the child invalidates itself. |
protected void |
laidout()
Invoked whenever the container layouting procedure has been finished. |
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 at the specified index from this container.
|
void |
remove(LwComponent c)
Removes the specified component from this container.
|
void |
removeAll()
Removes all child components from this container.
|
void |
setBackground(java.awt.Color c)
Sets the background color of this container. |
void |
setLwLayout(LwLayout m)
Sets the layout manager for this container. |
void |
setOpaque(boolean b)
Sets the opaque of this component. |
void |
setSize(int w,
int h)
Sets the specified size for this component. |
void |
toFront(LwComponent c)
Sets the specified child component to be painted over other child components. |
protected void |
updateCashedPs(int w,
int h)
The method for internal usage only ! |
void |
validate()
Invoked with validate method only if the component is not valid.
|
| 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, repaint, 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, repaint, repaint, setEnabled, setInsets, setLwParent, setViewMan, setVisible, update |
children
protected java.util.Vector children
LwPanel
public LwPanel()
- Constructs the container.
paintOnTop
public void paintOnTop(java.awt.Graphics g)
- Description copied from interface:
LwContainer
- Paints additional elements (for example marker) after the container and its child components
have been rendered.
- Specified by:
paintOnTop in interface LwContainer
- Following copied from interface:
org.zaval.lw.LwContainer
- Parameters:
g - the graphics context.
add
public void add(java.lang.Object s,
LwComponent c)
- Adds the specified lightweight component with the specified constraints as a child
of this container. The method calls
componentAdded method its
layout manager to inform the layout manager that the new child has been added with
the given constraints.
- Specified by:
add in interface LwContainer
- Parameters:
s - the object expressing layout constraints for this.c - the lightweight component to be added.
add
public void add(LwComponent c)
- Adds the specified lightweight component as a child of this container.
The method calls
componentAdded method its layout manager to inform
the layout manager that the new child has been added.
- Specified by:
add in interface LwContainer
- Parameters:
c - the lightweight component to be added.
insert
public void insert(int i,
LwComponent d)
- Inserts the specified lightweight component as a child of this container
at the specified position in the container list. The method calls
componentAdded method its layout manager to inform the layout manager
that the new child has been added.
- Parameters:
i - the position in the container list at which to insert
the component.d - the lightweight component to be added.
insert
public 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. The method calls
componentAdded method its layout manager to inform the layout manager
that the new child has been added with the given constraints.
- Specified by:
insert in interface LwContainer
- Parameters:
i - the position in the container list at which to insert
the component.s - the object expressing layout contraints for this.d - the lightweight component to be added.
remove
public void remove(LwComponent c)
- Removes the specified component from this container.
The layout manager of this container is informed by calling
componentRemoved method of the manager.
- Parameters:
c - the specified component to be removed.
remove
public void remove(int i)
- Removes the component at the specified index from this container.
The layout manager of this container is informed by calling
componentRemoved method of the manager.
- Specified by:
remove in interface LwContainer
- Parameters:
i - the index of the component to be removed.
removeAll
public void removeAll()
- Removes all child components from this container.
The layout manager of this container is informed by calling
componentRemoved method of the manager for every child that has been
removed.
- Specified by:
removeAll in interface LwContainer
indexOf
public int indexOf(LwComponent c)
- Searches the specified component among this container children and returns
an index of the component in the child list. If the component has not been found
than the method returns -1.
- Specified by:
indexOf in interface LwContainer
- Parameters:
c - the component to get index.- Returns:
- the child index.
get
public Layoutable get(int i)
- Gets a child component at the given index.
- Specified by:
get in interface LayoutContainer
- Parameters:
i - the specified index of the child to be returned.- Returns:
- a child component at the specified index.
count
public int count()
- Returns the number of child components in this container.
- Specified by:
count in interface LayoutContainer
- Returns:
- a number of child components in this container.
setLwLayout
public void setLwLayout(LwLayout m)
- Sets the layout manager for this container. It is impossible to use
null
as a layout manager, in this case IllegalArgumentException will be thrown.
- Specified by:
setLwLayout in interface LwContainer
- Parameters:
m - the specified layout manager.
getLwLayout
public LwLayout getLwLayout()
- Gets the layout manager of this container.
- Specified by:
getLwLayout in interface LwContainer
- Returns:
- a layout manager.
setBackground
public void setBackground(java.awt.Color c)
- Sets the background color of this container. Additionally the method sets the background color
for every child component.
- Specified by:
setBackground in interface LwComponent- Overrides:
setBackground in class LwCanvas
- Parameters:
c - the color to become this component background color.
setOpaque
public void setOpaque(boolean b)
- Sets the opaque of this component. Use
false
argument value to make a transparent component from this component.
Additionally the method sets the specified opaque for every child component.
- Specified by:
setOpaque in interface LwComponent- Overrides:
setOpaque in class LwCanvas
- Parameters:
b - the opaque flag.
getLwComponentAt
public LwComponent getLwComponentAt(int xx,
int yy)
- Determines if the component or an immediate child component contains the
(xx, yy) location in its visible part and if so, returns the component.
- Specified by:
getLwComponentAt in interface LwComponent- Overrides:
getLwComponentAt in class LwCanvas
- Parameters:
xx - the x coordinate.yy - the y coordinate.- Returns:
- the component or sub-component that contains the (x, y) location;
null if the location is outside of this component visible part.
toFront
public void toFront(LwComponent c)
- Sets the specified child component to be painted over other child components.
- Parameters:
c - the specified child component.
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Description copied from interface:
Layoutable
- Gets the preferred size of this component. The preferred size is the size that the component wants to have.
- Specified by:
getPreferredSize in interface Layoutable- Overrides:
getPreferredSize in class LwCanvas
- Following copied from interface:
org.zaval.lw.Layoutable
- Returns:
- a dimension object indicating this component preferred size.
validate
public void validate()
- Invoked with
validate method only if the component is not valid.
The method should not be overridden for this container like it can be done for LwCanvas,
because the method starts validating and layouting of the child components.
- Specified by:
validate in interface Validationable- Overrides:
validate in class LwCanvas
isInvalidatedByChild
public boolean isInvalidatedByChild(LwComponent c)
- Description copied from interface:
LwContainer
- Invoked by a child component whenever the child invalidates itself. Usually a child component
invalidate its parent. The method provides ability to control container invalidation by the
specified child component. The child asks the container if it should be invalidated by the
calling the method.
- Specified by:
isInvalidatedByChild in interface LwContainer
- Following copied from interface:
org.zaval.lw.LwContainer
- Parameters:
c - the child component that wants to invalidate the container.- Returns:
true if the container should be invalidated by the child component;
false otherwise.
setSize
public void setSize(int w,
int h)
- Description copied from interface:
Layoutable
- Sets the specified size for this component.
- Specified by:
setSize in interface Layoutable- Overrides:
setSize in class LwCanvas
- Following copied from interface:
org.zaval.lw.Layoutable
- Parameters:
w - the width of this component.h - the height of this component.
getLayoutOffset
public java.awt.Point getLayoutOffset()
- Returns the offset. The offset can be used with a layout manager to offset child components
locations of the container according to the offset values. The offset is represented
with java.awt.Point class, the
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.
- Specified by:
getLayoutOffset in interface LayoutContainer
- Returns:
- an offset to move children.
invalidate
public void invalidate()
- Description copied from interface:
Validationable
- Invalidates this object.
- Specified by:
invalidate in interface Validationable- Overrides:
invalidate in class LwCanvas
calcPreferredSize
protected java.awt.Dimension calcPreferredSize()
- Gets the "pure" preferred size for this component. The method has not be overridden,
because it determines the preferred size by the layout manager.
- Overrides:
calcPreferredSize in class LwCanvas
- Returns:
- a "pure" preferred size.
getDefaultLayout
protected LwLayout getDefaultLayout()
- 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.
- Returns:
- a layout manager.
updateCashedPs
protected void updateCashedPs(int w,
int h)
- The method for internal usage only !
laidout
protected void laidout()
- Invoked whenever the container layouting procedure has been finished.
|