org.zaval.lw
Interface LwComponent
- All Superinterfaces:
- Layoutable, Validationable
- All Known Subinterfaces:
- LwComposite, LwContainer, LwDesktop, LwLayer
- All Known Implementing Classes:
- LwCanvas
- public interface LwComponent
- extends Layoutable
This is base interface for the library components. Any GUI component of the library should
implement the interface. Actually the interface is analog of the java.awt.Component class
provided by the Java AWT library. The lightweight library provides an implementation of the
interface - LwCanvas - that is more handy for usage. To create a lightweight component
just inherit the class. The another variation of the interface is the lightweight container
interface - LwContainer. The interface extends the component interface and has implementation
to create own lightweight containers - LwPanel.
|
Method Summary |
boolean |
canHaveFocus()
Specifies if the component can have focus. |
java.awt.Color |
getBackground()
Gets the background color of this component. |
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. |
LwComponent |
getLwParent()
Gets the lightweight parent of this component. |
java.awt.Point |
getOrigin()
Returns an origin of the component. |
LwViewMan |
getViewMan(boolean autoCreate)
Returns a view manager of the component. |
java.awt.Rectangle |
getVisiblePart()
Returns the bounding rectangle of the visible part for the component. |
boolean |
isEnabled()
Determines whether this component is enabled. |
boolean |
isOpaque()
Gets the opaque of this component. |
void |
paint(java.awt.Graphics g)
Paints this component. |
void |
repaint()
Performs repainting process of this component. |
void |
repaint(boolean b)
Invoked whenever the component got or lost the focus. |
void |
repaint(int x,
int y,
int w,
int h)
Performs repainting process of the specified rectangular area of this component. |
void |
setBackground(java.awt.Color c)
Sets the background color of this component. |
void |
setEnabled(boolean b)
Enables or disables this component. |
void |
setInsets(int top,
int left,
int bottom,
int right)
Sets the specified insets for the component. |
void |
setLwParent(LwComponent p)
Sets the lightweight parent of this component. |
void |
setOpaque(boolean b)
Sets the opaque of this component. |
void |
setViewMan(LwViewMan man)
Sets the specified view manager for the component. |
void |
setVisible(boolean b)
Shows or hides this lightweight component depending on the value of parameter
b. |
void |
update(java.awt.Graphics g)
Updates this component. |
| Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize |
getVisiblePart
public java.awt.Rectangle getVisiblePart()
- Returns the bounding rectangle of the visible part for the component.
- Returns:
- a visible part bounding rectangle.
getLwComponentAt
public 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.
- 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.
getLwParent
public LwComponent getLwParent()
- Gets the lightweight parent of this component. It is supposed that the parent implements
LwContainer interface.
- Returns:
- the parent container of this component.
setLwParent
public void setLwParent(LwComponent p)
- Sets the lightweight parent of this component. It is supposed that the parent implements
LwContainer interface. The method is provided for lightweight core usage to support components
hierarchy, not for applications that base on the library. Don't touch
the method.
- Parameters:
p - the specified parent container.
setEnabled
public void setEnabled(boolean b)
- Enables or disables this component. An enabled component can participate
in events handling and performing processes. Component is enabled
by default.
- Parameters:
b - if the value is true - enables the component;
otherwise disables this component.
setVisible
public void setVisible(boolean b)
- Shows or hides this lightweight component depending on the value of parameter
b.
- Parameters:
b - if it is true, shows this component;
otherwise, hides this component.
setBackground
public void setBackground(java.awt.Color c)
- Sets the background color of this component. The color is going to be used to
fill the component background.
- Parameters:
c - the color to become this component background color.
getViewMan
public LwViewMan getViewMan(boolean autoCreate)
- Returns a view manager of the component. The view manager can be
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.
- Parameters:
autoCreate - the flag defines if the view manager should be created
automatically.- Returns:
- a view manager for the component.
setViewMan
public void setViewMan(LwViewMan man)
- Sets the specified view manager for the component. The view manager defines set of views
that are used as a part of the component face.
- Parameters:
man - the view manager to set for the component.
canHaveFocus
public boolean canHaveFocus()
- Specifies if the component can have focus.
- Returns:
true if the component can have the focus.
paint
public void paint(java.awt.Graphics g)
- Paints this component.
- Parameters:
g - the graphics context to be used for painting.
update
public void update(java.awt.Graphics g)
- Updates this component. The calling of the method precedes
the calling of
paint method and it is performed with
repaint method. The method can be used to fill the
component with the background color if the component is opaque.
- Parameters:
g - the specified context to be used for updating.
repaint
public void repaint()
- Performs repainting process of this component. The method causes
calling of
update and than paint methods.
repaint
public void repaint(int x,
int y,
int w,
int h)
- Performs repainting process of the specified rectangular area of this component. The method causes
calling of
update and than paint methods.
- Parameters:
x - the x coordinate.y - the y coordinate.w - the width.h - the height.
isOpaque
public boolean isOpaque()
- Gets the opaque of this component. If the method returns
false than the component is transparent, in this case
update method is not be called during painting process.
- Returns:
true if the component is opaque; otherwise
false.
setOpaque
public void setOpaque(boolean b)
- Sets the opaque of this component. Use
false
argument value to make a transparent component from this component.
- Parameters:
b - the opaque flag.
getOrigin
public java.awt.Point getOrigin()
- Returns an origin of the component. The origin defines an offset of the component view
relatively the component point of origin. The method can be implemented to organize
scrolling of the component view.
- Returns:
- an origin of the component.
getBackground
public java.awt.Color getBackground()
- Gets the background color of this component.
- Returns:
- a component background color.
isEnabled
public boolean isEnabled()
- Determines whether this component is enabled. If the method returns
true than the component is enabled and can participate in event
handling and performing processes. Components are enabled initially by default.
- Returns:
true if the component is enabled; false otherwise.
setInsets
public void setInsets(int top,
int left,
int bottom,
int right)
- Sets the specified insets for the component.
- Parameters:
top - the top indent.left - the left indent.bottom - the bottom indent.right - the right indent.
repaint
public void repaint(boolean b)
- Invoked whenever the component got or lost the focus. The method is supposed to optimize
the performance of the focus marker, since in most cases it is not necessary to repaint
all component area. By default the method repaint all component area.
- Parameters:
b - true if the component has got the focus, and false
if the component lost the focus.
|