|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.lwuit.Component com.sun.lwuit.Container
public class Container
A composite pattern with Component
, allows nesting and arranging multiple
components using a pluggable layout manager architecture. Containers can be nested
one within the other to form elaborate UI's.
com.sun.lwuit.layouts
,
Component
Field Summary |
---|
Fields inherited from class com.sun.lwuit.Component |
---|
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP |
Constructor Summary | |
---|---|
Container()
Constructs a new Container, with a FlowLayout . |
|
Container(Layout layout)
Constructs a new Container with a new layout manager. |
Method Summary | |
---|---|
void |
addComponent(Component cmp)
Adds a Component to the Container |
void |
addComponent(int index,
Component cmp)
This method adds the Component at a specific index location in the Container Components array. |
void |
addComponent(int index,
java.lang.Object constraints,
Component cmp)
Adds a Component to the Container |
void |
addComponent(java.lang.Object constraints,
Component cmp)
Adds a Component to the Container |
void |
animateLayout(int duration)
Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation |
void |
animateLayoutAndWait(int duration)
Animates a pending layout into place, this effectively replaces revalidate with a more visual form of animation. |
void |
applyRTL(boolean rtl)
Invokes apply/setRTL recursively on all the children components of this container |
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content. |
boolean |
contains(Component cmp)
Returns true if the given component is within the hierarchy of this container |
protected void |
dragInitiated()
Invoked on the focus component to let it know that drag has started on the parent container for the case of a component that doesn't support scrolling |
void |
drop(Component dragged,
int x,
int y)
Performs a drop operation of the component at the given X/Y location in coordinate space, this method should be overriden by subclasses to perform all of the logic related to moving a component, by default this method does nothing and so dragging a component and dropping it has no effect |
Component |
findFirstFocusable()
Finds the first focusable Component on this Container |
void |
flushReplace()
Flushes ongoing replace operations to prevent two concurrent replace operations from colliding. |
int |
getBottomGap()
Returns the gap to be left for the bottom scrollbar on the X axis. |
Component |
getComponentAt(int index)
Returns the Component at a given index |
Component |
getComponentAt(int x,
int y)
Returns a Component that exists in the given x, y coordinates by traversing component objects and invoking contains |
int |
getComponentCount()
Returns the number of components |
int |
getComponentIndex(Component cmp)
Returns the Component index in the Container |
protected int |
getGridPosX()
This method should be implemented correctly by subclasses to make snap to grid functionality work as expected. |
protected int |
getGridPosY()
This method should be implemented correctly by subclasses to make snap to grid functionality work as expected. |
Layout |
getLayout()
Returns the layout manager responsible for arranging this container |
int |
getLayoutHeight()
Returns the height for layout manager purposes, this takes scrolling into consideration unlike the getWidth method. |
int |
getLayoutWidth()
Returns the width for layout manager purposes, this takes scrolling into consideration unlike the getWidth method. |
Component |
getLeadComponent()
Returns the lead component for this hierarchy if such a component is defined |
Container |
getLeadParent()
Returns the lead container thats handling the leading, this is useful for a container hierachy where the parent container might not be the leader |
int |
getScrollIncrement()
Gets the Container scroll increment |
int |
getSideGap()
Returns the gap to be left for the side scrollbar on the Y axis. |
void |
invalidate()
Same as setShouldCalcPreferredSize(true) but made accessible for layout managers |
boolean |
isEnabled()
Indicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visually |
boolean |
isScrollableX()
Indicates whether the component should/could scroll on the X axis |
boolean |
isScrollableY()
Indicates whether the component should/could scroll on the Y axis |
void |
keyPressed(int k)
If this Component is focused, the key pressed event will call this method |
void |
keyReleased(int k)
If this Component is focused, the key released event will call this method |
void |
layoutContainer()
Performs the layout of the container if a layout is necessary |
void |
paint(Graphics g)
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering. |
void |
paintBackground(Graphics g)
Paints the background of the component, invoked with the clipping region and appropriate scroll translation. |
protected void |
paintGlass(Graphics g)
This method can be overriden by a component to draw on top of itself or its children after the component or the children finished drawing in a similar way to the glass pane but more refined per component |
protected java.lang.String |
paramString()
Returns a string representing the state of this component. |
void |
pointerHover(int[] x,
int[] y)
Invoked for devices where the pointer can hover without actually clicking the display. |
void |
pointerPressed(int x,
int y)
If this Component is focused, the pointer pressed event will call this method |
void |
refreshTheme()
Makes sure the component is up to date with the current style object |
void |
removeAll()
remove all Components from container, notice that removed component might still have a pending repaint in the queue that won't be removed. |
void |
removeComponent(Component cmp)
removes a Component from the Container, notice that removed component might still have a pending repaint in the queue that won't be removed. |
void |
replace(Component current,
Component next,
Transition t)
This method replaces the current Component with the next Component. |
void |
replace(Component current,
Component next,
Transition t,
java.lang.Runnable onFinish,
int growSpeed)
This method replaces the current Component with the next Component |
void |
replaceAndWait(Component current,
Component next,
Transition t)
This method replaces the current Component with the next Component. |
void |
replaceAndWait(Component current,
Component next,
Transition t,
boolean dropEvents)
This method replaces the current Component with the next Component. |
void |
replaceAndWait(Component current,
Component next,
Transition t,
int layoutAnimationSpeed)
This method replaces the current Component with the next Component. |
void |
revalidate()
Re-layout the container, this is useful when we modify the container hierarchy and need to redo the layout |
protected void |
scrollComponentToVisible(Component c)
Makes sure the component is visible in the scroll if this container is scrollable |
void |
setCellRenderer(boolean cellRenderer)
Used as an optimization to mark that this component is currently being used as a cell renderer |
void |
setEnabled(boolean enabled)
This method will recursively set all the Container chidrens to be enabled/disabled. |
void |
setLayout(Layout layout)
Sets the layout manager responsible for arranging this container |
void |
setLeadComponent(Component lead)
Sets the lead component for this container, a lead component takes over the entire component hierarchy and receives all the events for the container hierarchy. |
void |
setScrollable(boolean scrollable)
The equivalent of calling both setScrollableY and setScrollableX |
void |
setScrollableX(boolean scrollableX)
Sets whether the component should/could scroll on the X axis |
void |
setScrollableY(boolean scrollableY)
Sets whether the component should/could scroll on the Y axis |
void |
setScrollIncrement(int scrollIncrement)
Determines the scroll increment size of this Container. |
void |
setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
Indicates the values within the component have changed and preferred size should be recalculated |
protected void |
setShouldLayout(boolean layout)
Flags this container to preform layout |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Container(Layout layout)
layout
- the specified layout managerpublic Container()
FlowLayout
.
Method Detail |
---|
public void setLeadComponent(Component lead)
lead
- component that takes over the hierarchypublic Component getLeadComponent()
public Container getLeadParent()
public void keyPressed(int k)
Component
keyPressed
in class Component
k
- the key code value to indicate a physical key.public void keyReleased(int k)
Component
keyReleased
in class Component
k
- the key code value to indicate a physical key.public Layout getLayout()
public void setLayout(Layout layout)
layout
- the specified layout managerpublic void invalidate()
protected void setShouldLayout(boolean layout)
layout
- public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
Component
setShouldCalcPreferredSize
in class Component
shouldCalcPreferredSize
- indicate whether this component need to
recalculate his preferred sizepublic int getLayoutWidth()
public int getLayoutHeight()
public void applyRTL(boolean rtl)
rtl
- right to left bidi indicationComponent.setRTL(boolean)
public void addComponent(Component cmp)
cmp
- the component to be addedpublic void addComponent(java.lang.Object constraints, Component cmp)
constraints
- this method is useful when the Layout requires a constraint
such as the BorderLayout.
In this case you need to specify an additional data when you add a Component,
such as "CENTER", "NORTH"...cmp
- component to addpublic void addComponent(int index, java.lang.Object constraints, Component cmp)
index
- location to insert the Componentconstraints
- this method is useful when the Layout requires a constraint
such as the BorderLayout.
In this case you need to specify an additional data when you add a Component,
such as "CENTER", "NORTH"...cmp
- component to addpublic void addComponent(int index, Component cmp)
index
- location to insert the Componentcmp
- the Component to add
java.lang.ArrayIndexOutOfBoundsException
- if index is out of bounds
java.lang.IllegalArgumentException
- if Component is already contained or
the cmp is a Form Componentpublic void replaceAndWait(Component current, Component next, Transition t)
current
- a Component to remove from the Containernext
- a Component that replaces the current Componentt
- a Transition between the add and removal of the Components
a Transition can be nullpublic void replaceAndWait(Component current, Component next, Transition t, int layoutAnimationSpeed)
current
- a Component to remove from the Containernext
- a Component that replaces the current Componentt
- a Transition between the add and removal of the Components
a Transition can be nulllayoutAnimationSpeed
- the speed of the layout animation after replace is completedpublic void replace(Component current, Component next, Transition t, java.lang.Runnable onFinish, int growSpeed)
current
- a Component to remove from the Containernext
- a Component that replaces the current Componentt
- a Transition between the add and removal of the Components
a Transition can be nullonFinish
- invoked when the replace operation is completed, may be nullgrowSpeed
- after replace is completed the component can gradually grow/shrink to fill up
available room, set this to 0 for immediate growth or any larger number for gradual animation. -1 indicates
a special case where no validation occurspublic void replaceAndWait(Component current, Component next, Transition t, boolean dropEvents)
current
- a Component to remove from the Containernext
- a Component that replaces the current Componentt
- a Transition between the add and removal of the Components
a Transition can be nulldropEvents
- indicates if the display should drop all events
while this Component replacing is happeningpublic void replace(Component current, Component next, Transition t)
current
- a Component to remove from the Containernext
- a Component that replaces the current Componentt
- a Transition between the add and removal of the Components
a Transition can be nullpublic boolean isEnabled()
Component
isEnabled
in class Component
public void removeComponent(Component cmp)
cmp
- the removed componentpublic void flushReplace()
public void removeAll()
public void revalidate()
public void paint(Graphics g)
Component
paint
in interface Animation
paint
in class Component
g
- the component graphicsprotected void paintGlass(Graphics g)
g
- the graphics contextpublic void layoutContainer()
public int getComponentCount()
public Component getComponentAt(int index)
index
- of the Component you wish to get
java.lang.ArrayIndexOutOfBoundsException
- if an invalid index was given.public int getComponentIndex(Component cmp)
cmp
- the component to search for
public boolean contains(Component cmp)
cmp
- a Component to check
protected void scrollComponentToVisible(Component c)
c
- the component that will be scrolling for visibilitypublic Component getComponentAt(int x, int y)
x
- absolute screen locationy
- absolute screen location
Component.contains(int, int)
public void pointerHover(int[] x, int[] y)
Component
pointerHover
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerPressed(int x, int y)
Component
pointerPressed
in class Component
x
- the pointer x coordinatey
- the pointer y coordinateprotected Dimension calcPreferredSize()
Component
calcPreferredSize
in class Component
protected java.lang.String paramString()
Component
null
.
paramString
in class Component
public void refreshTheme()
Component
refreshTheme
in class Component
public boolean isScrollableX()
Component
isScrollableX
in class Component
public boolean isScrollableY()
Component
isScrollableY
in class Component
public int getSideGap()
Component
getSideGap
in class Component
public int getBottomGap()
Component
getBottomGap
in class Component
public void setScrollableX(boolean scrollableX)
scrollableX
- whether the component should/could scroll on the X axispublic void setScrollableY(boolean scrollableY)
scrollableY
- whether the component should/could scroll on the Y axispublic void setScrollable(boolean scrollable)
scrollable
- whether the component should/could scroll on the
X and Y axispublic void setCellRenderer(boolean cellRenderer)
Component
setCellRenderer
in class Component
cellRenderer
- indicate whether this component is currently being
used as a cell rendererpublic void setScrollIncrement(int scrollIncrement)
scrollIncrement
- the size in pixels.public int getScrollIncrement()
public Component findFirstFocusable()
protected void dragInitiated()
Component
dragInitiated
in class Component
public void setEnabled(boolean enabled)
setEnabled
in class Component
enabled
- protected int getGridPosY()
Component
getGridPosY
in class Component
public void paintBackground(Graphics g)
Component
paintBackground
in class Component
g
- the component graphicsprotected int getGridPosX()
Component
getGridPosX
in class Component
public void animateLayoutAndWait(int duration)
duration
- the duration in milliseconds for the animationpublic void animateLayout(int duration)
duration
- the duration in milliseconds for the animationpublic void drop(Component dragged, int x, int y)
Component
drop
in class Component
dragged
- the component being droppedx
- the x coordinate of the dropy
- the y coordinate of the drop
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |