public class Container extends Component
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
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
Constructor and Description |
---|
Container()
Constructs a new Container, with a
FlowLayout . |
Container(Layout layout)
Constructs a new Container with a new layout manager.
|
Modifier and Type | Method and Description |
---|---|
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,
Object constraints,
Component cmp)
Adds a Component to the Container
|
void |
addComponent(Object constraints,
Component cmp)
Adds a Component to the Container
|
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
|
void |
flushReplace()
Flushes ongoing replace operations to prevent two concurrent replace operations from colliding.
|
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
|
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.
|
int |
getScrollIncrement()
Gets the Container scroll increment
|
void |
invalidate()
Same as setShouldCalcPreferredSize(true) but made accessible for
layout managers
|
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 |
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.
|
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 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
|
void |
removeComponent(Component cmp)
removes a Component from the Container
|
void |
replace(Component current,
Component next,
Transition t)
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 |
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 |
setLayout(Layout layout)
Sets the layout manager responsible for arranging this container
|
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.
|
protected 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
|
addFocusListener, animate, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragInitiated, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getHeight, getLabelForComponent, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getScrollAnimationSpeed, getScrollDimension, getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getSideGap, getStyle, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, handlesInput, hasFocus, initComponent, initCustomStyle, isBorderPainted, isDragActivated, isEnabled, isFocusable, isFocusPainted, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setBorderPainted, setDirtyRegion, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setLabelForComponent, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setRTL, setScrollAnimationSpeed, setScrollSize, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setStyle, setTactileTouch, setTensileDragEnabled, setUIID, setUnselectedStyle, setUnSelectedStyle, setVisible, setWidth, setX, setY, styleChanged, toString
public Container(Layout layout)
layout
- the specified layout managerpublic Container()
FlowLayout
.public Layout getLayout()
public void setLayout(Layout layout)
layout
- the specified layout managerpublic void invalidate()
protected void setShouldLayout(boolean layout)
layout
- protected 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(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, 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 addArrayIndexOutOfBoundsException
- if index is out of boundsIllegalArgumentException
- 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 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 void removeComponent(Component cmp)
cmp
- the removed componentpublic void flushReplace()
public void removeAll()
public void revalidate()
public void paint(Graphics g)
Component
protected 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 getArrayIndexOutOfBoundsException
- if an invalid index was given.public int getComponentIndex(Component cmp)
cmp
- the component to search forpublic boolean contains(Component cmp)
cmp
- a Component to checkprotected 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 locationComponent.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 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 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()