|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Object
Component
public class Component
Component is base class for user interface elements. Most of the access methods are available through this class even if the actual instance might not support them. Rationale for this is to improve the usability of API so that need for explicit casting is minimized.
Every component has flags that define some basic properties of it and the way other components are positioned inside it. The existing flags are:
VISIBLE - visible or not
FOCUSABLE - can the user or UI focus to the element.
LINEFEED - no more components will appear on the same
horizontal height on the right side
WRAP - When components are set horizontally one after
another any component that won't fit on that line will be
placed on the next line.
| Constructor Summary | |
|---|---|
Component(Style style)
Creates a new component with the specified style. |
|
| Method Summary | |
|---|---|
Component |
add(Component child)
Adds the given component to end of this container. |
Component |
appendText(String text)
Sets the more text into Text or Input component. |
void |
clear()
Clears all children from container. |
Component |
find(Object data)
Searches for component with matching data attachment. |
Component |
first()
Returns the first component on container. |
Component |
get(int index)
Returns the component at the specified index. |
int |
getAction()
Gets the explicit "fire" action associated with this component. |
Object |
getData()
Gets the data attachment associated with this component. |
Component |
getElement(String name)
Returns named component from View. |
int |
getFlags()
Return the current flags of this component |
Image |
getImage()
Return the current image of Label or Picture component. |
int, int |
getLocation()
Returns the coordinate of component. |
Component |
getParent()
Return the parent component. |
Shell |
getShell()
Returns the root Shell of component tree. |
int, int |
getSize()
Returns the realized width and height of this Component. |
Style |
getStyle()
Returns the current style of this component. |
String |
getText()
Return the current text of Label, Text or Input component. |
Scrollable |
getViewPort()
Searches for Scrollable among the parents of this Component. |
boolean |
hasLinefeed()
Return the current state of LINEFEED flag. |
int |
indexOf(Component child)
Returns the index of specified child in container. |
Component |
insert(int index,
Component child)
Inserts the given component to specified index in this container. |
boolean |
isFocusable()
Return the current state of FOCUSABLE flag. |
boolean |
isShown()
Checks if the given component is shown on screen. |
boolean |
isVisible()
Return the current state of VISIBLE flag. |
boolean |
isWrapping()
Return the current state of WRAP flag. |
Component |
last()
Returns the last component on container. |
Component |
operator_get(int index)
Returns the component at the specified index. |
Component |
operator_set(int index,
Component child)
Sets the component at the specified index. |
Component |
remove(Component child)
Removes the given component. |
Component |
remove(int index)
Removes the component at specified index. |
void |
repaint(boolean refreshLayout)
Adds this component is repaint queue. |
Component |
set(int index,
Component child)
Sets the given component at specified index in this container. |
Component |
setAction(int action)
Sets the explicit "fire" action. |
Component |
setData(Object data)
Sets the data attachment to this component. |
Component |
setElement(String name,
Component element)
Sets named component in this View. |
Component |
setFlags(int flags)
Sets the flags of this component. |
Component |
setImage(Image image)
Sets the image of Label and Picture component. |
Component |
setLocation(int x,
int y)
Sets the location of this component. |
Component |
setPreferredHeight(int height)
Sets the preferred height of this Component. |
Component |
setPreferredSize(int width,
int height)
Sets preferred width and height for this Component. |
Component |
setPreferredWidth(int width)
Sets the preferred width of this Component. |
Component |
setStyle(Style style)
Sets the style of this Component. |
Component |
setText(String text)
Sets the text of Label, Text or Input component. |
int |
size()
Returns the number of children in container. |
| Methods inherited from class Object |
|---|
toString, equals, hashCode |
| Methods inherited from |
|---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Component(Style style)
Component does not
paint any content the style is nevertheless painted and
hence it can be used for decorative purposes.
style - Component style| Method Detail |
|---|
public Style getStyle()
setStyle(Style)public Object getData()
setData(Object)public int getAction()
FOCUSABLE flag set, since the user can't focus on it.
setAction(int),
FOCUSABLEpublic Component getParent()
add(Component),
insert(int, Component),
set(int, Component),
remove(int)public Scrollable getViewPort()
Scrollable among the parents of this Component.
If this component is Scrollable, returns this
null if there is no
scrollable on component treepublic Shell getShell()
public boolean hasLinefeed()
LINEFEED flag.
LINEFEEDpublic boolean isVisible()
VISIBLE flag.
VISIBLEpublic boolean isFocusable()
FOCUSABLE flag.
FOCUSABLEpublic boolean isWrapping()
WRAP flag.
WRAPpublic int getFlags()
VISIBLE,
FOCUSABLE,
LINEFEED,
WRAPpublic String getText()
Label, Text or Input component.
Returns null for all other components.
nullLabel,
Text,
Inputpublic Image getImage()
Label or Picture component.
Returns null for all other components.
nullLabel,
Picturepublic Component setStyle(Style style)
style - New stylegetStyle(),
repaint(boolean),
flushScreen(boolean)public Component setData(Object data)
data - data attachment
getData()public Component setAction(int action)
FOCUSABLE flag set.
action - Fire actiongetAction(),
FOCUSABLEpublic Component setFlags(int flags)
flags - Flags to set
VISIBLE,
FOCUSABLE,
LINEFEED,
WRAPpublic Component setPreferredWidth(int width)
1.. : Absolute width
0 : Optimal width, calculated automatically
-100..-1: Relative width (1%..100%),
calculated from available space
width - desired width
setPreferredHeight(int),
setPreferredSize(int, int),
getSize()public Component setPreferredHeight(int height)
1.. : Absolute height
0 : Optimal height, calculated automatically
-100..-1: Relative height (1%..100%),
calculated from available space
height - desired height
setPreferredWidth(int),
setPreferredSize(int, int),
getSize()
public Component setPreferredSize(int width,
int height)
width - desired widthheight - desired heightsetPreferredWidth(int),
setPreferredHeight(int)public int, int getSize()
(int width, int height) tuple.public int, int getLocation()
(int x, int y) tuple.
public Component setLocation(int x,
int y)
Surface, all other usages will
be ignored.
x - Absolute X position of componenty - Absolute Y position of component
public int size()
Flow, Scrollable and Shell.
Flow,
Scrollable,
Shellpublic int indexOf(Component child)
-1 if child was not foundpublic void clear()
Flow component.
public void repaint(boolean refreshLayout)
Script.keyAction(Component, int, int)
Script.actionPerformed(Shell, Component, int)
Script.getMenu(Shell, Component)
Script.getSoftKey(Shell, Component, int)
Script.openWidget()
Script.paint(Component, Graphics, Style, int, int)
Otherwise handling is requested with
flushScreen(boolean) method. Queue
is optimized so that no Component is repainted
twice.
refreshLayout - Flag to indicate if the layout of component should be re-computed.
Computation occurs prior painting. It is highly recommended to
optimize code so that true is supplied only if
component tree contents or styles have changed.public Component first()
This method is equal to call component.get(0).
first(),
size(),
get(int)public Component last()
This method is equal to call component.get(component.size()-1).
last(),
size(),
get(int)public Component get(int index)
index - Index to container,
must be on range [0..size()-1].
size()public Component find(Object data)
data - Data attachment to search for
null null if no match was foundpublic Component getElement(String name)
Flow container
created using createView(String, Object).
name - Name of element to return
null if there is no such
element on View.
public Component setElement(String name,
Component element)
Flow container
created using createView(String, Object).
name - Name of element to overrideelement - Component to set
public Component remove(int index)
Flow component.
index - Index of component to remove,
must be on range [0..size()-1].
public Component remove(Component child)
Flow component.
child - Component to remove
public Component add(Component child)
Flow component.
child - Component to add
public Component set(int index,
Component child)
Flow component.
index - Index to container,
must be on range [0..size()-1].child - Component to set
public Component insert(int index,
Component child)
Flow component.
index - Index to container,
must be on range [0..size()].child - Component to add
public Component setText(String text)
Label, Text or Input component.
text - Text to set
public Component appendText(String text)
Text or Input component.
text - Text to append
public Component setImage(Image image)
Label and Picture component.
image - Image to set
public Component operator_get(int index)
index - Index to container
size()
public Component operator_set(int index,
Component child)
index - Index to container,
must be on range [0..size()-1].child - Child component
size()public boolean isShown()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||