Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit
Class Container

java.lang.Object
  extended by com.sun.dtv.lwuit.Component
      extended by com.sun.dtv.lwuit.Container
All Implemented Interfaces:
Animation, StyleListener, Animated, MatteEnabled
Direct Known Subclasses:
Calendar, DTVContainer, Form, TabbedPane

public class Container
extends Component
implements MatteEnabled

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.

See Also:
Layout, Component

Field Summary
 
Fields inherited from class com.sun.dtv.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Fields inherited from interface com.sun.dtv.ui.Animated
ALTERNATING, LOOP, REPEATING
 
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(Object constraints, Component cmp)
          Adds a Component to the Container.
 boolean contains(Component cmp)
          Returns true if the given component is within the hierarchy of this container.
 void doLayout()
          Lays out the container.
 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.
 Matte getMatte()
          Return the Matte currently associated with the component implementing this interface.
 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.
 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 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 setMatte(Matte matte)
          Adds an Matte to the component implementing this interface in order to enable matte compositing.
 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.
 
Methods inherited from class com.sun.dtv.lwuit.Component
addFocusListener, animate, calcPreferredSize, contains, deinitialize, getAbsoluteX, getAbsoluteY, getAnimationMode, getBaseline, getBaselineResizeBehavior, getBottomGap, getBounds, getClientProperty, getComponentForm, getDelay, getHeight, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPosition, getPreferredSize, getRepetitionMode, getScrollAnimationSpeed, getScrollX, getScrollY, getSideGap, getStyle, getUIID, getWidth, getX, getY, handlesInput, hasFocus, initialize, isEnabled, isFocusable, isFocusPainted, isInitialized, isRunning, isScrollVisible, isSmoothScrolling, isVisible, jumpTo, keyPressed, keyReleased, keyRepeated, longKeyPress, paintBackgrounds, paintComponent, paintComponent, pointerDragged, pointerReleased, putClientProperty, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, setAnimationMode, setDelay, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredSize, setRepetitionMode, setScrollAnimationSpeed, setScrollX, setScrollY, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setStyle, setUIID, setVisible, setWidth, setX, setY, start, stop, styleChanged, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Container

public Container(Layout layout)
Constructs a new Container with a new layout manager.

Parameters:
layout - the specified layout manager

Container

public Container()
Constructs a new Container, with a FlowLayout.

Method Detail

getLayout

public Layout getLayout()
Returns the layout manager responsible for arranging this container.

Returns:
the container layout manager
See Also:
setLayout(com.sun.dtv.lwuit.layouts.Layout)

setLayout

public void setLayout(Layout layout)
Sets the layout manager responsible for arranging this container.

Parameters:
layout - the specified layout manager
See Also:
getLayout()

invalidate

public void invalidate()
Same as setShouldCalcPreferredSize(true) but made accessible for layout managers.


getLayoutWidth

public int getLayoutWidth()
Returns the width for layout manager purposes, this takes scrolling into consideration unlike the getWidth method.

Returns:
the layout width

getLayoutHeight

public int getLayoutHeight()
Returns the height for layout manager purposes, this takes scrolling into consideration unlike the getWidth method.

Returns:
the layout height

addComponent

public void addComponent(Component cmp)
Adds a Component to the Container.

Parameters:
cmp - the component to be added

addComponent

public void addComponent(Object constraints,
                         Component cmp)
Adds a Component to the Container.

Parameters:
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 add

addComponent

public void addComponent(int index,
                         Component cmp)
This method adds the Component at a specific index location in the Container Components array.

Parameters:
index - location to insert the Component
cmp - the Component to add
Throws:
ArrayIndexOutOfBoundsException - if index is out of bounds
IllegalArgumentException - if Component is already contained or the cmp is a Form Component

replace

public void replace(Component current,
                    Component next,
                    Transition t)
This method replaces the current Component with the next Component. Current Component must be contained in this Container. This method return immediately.

Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition can be null

removeComponent

public void removeComponent(Component cmp)
removes a Component from the Container.

Parameters:
cmp - the removed component

removeAll

public void removeAll()
remove all Components from container.


revalidate

public void revalidate()
Re-layout the container, this is useful when we modify the container hierarchy and need to redo the layout.


paint

public void paint(Graphics g)
Description copied from class: Component
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.

Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics

layoutContainer

public void layoutContainer()
Performs the layout of the container if a layout is necessary.


doLayout

public void doLayout()
Lays out the container.


getComponentCount

public int getComponentCount()
Returns the number of components.

Returns:
the Component count

getComponentAt

public Component getComponentAt(int index)
Returns the Component at a given index.

Parameters:
index - of the Component you wish to get
Returns:
a Component
Throws:
ArrayIndexOutOfBoundsException - if an invalid index was given.

getComponentIndex

public int getComponentIndex(Component cmp)
Returns the Component index in the Container.

Parameters:
cmp - the component to search for
Returns:
the Component index in the Container or -1 if not found

contains

public boolean contains(Component cmp)
Returns true if the given component is within the hierarchy of this container.

Parameters:
cmp - a Component to check
Returns:
true if this Component contains in this Container

getComponentAt

public Component getComponentAt(int x,
                                int y)
Returns a Component that exists in the given x, y coordinates by traversing component objects and invoking contains.

Parameters:
x - absolute screen location
y - absolute screen location
Returns:
a Component if found, null otherwise
See Also:
Component.contains(int, int)

pointerPressed

public void pointerPressed(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer pressed event will call this method.

Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

refreshTheme

public void refreshTheme()
Description copied from class: Component
Makes sure the component is up to date with the current style object.

Overrides:
refreshTheme in class Component

isScrollableX

public boolean isScrollableX()
Description copied from class: Component
Indicates whether the component should/could scroll on the X axis.

Overrides:
isScrollableX in class Component
Returns:
whether the component is scrollable on the X axis

isScrollableY

public boolean isScrollableY()
Description copied from class: Component
Indicates whether the component should/could scroll on the Y axis.

Overrides:
isScrollableY in class Component
Returns:
whether the component is scrollable on the X axis

setScrollableX

public void setScrollableX(boolean scrollableX)
Sets whether the component should/could scroll on the X axis.

Parameters:
scrollableX - whether the component should/could scroll on the X axis

setScrollableY

public void setScrollableY(boolean scrollableY)
Sets whether the component should/could scroll on the Y axis.

Parameters:
scrollableY - whether the component should/could scroll on the Y axis

setScrollable

public void setScrollable(boolean scrollable)
The equivalent of calling both setScrollableY and setScrollableX.

Parameters:
scrollable - whether the component should/could scroll on the X and Y axis

setCellRenderer

public void setCellRenderer(boolean cellRenderer)
Description copied from class: Component
Used as an optimization to mark that this component is currently being used as a cell renderer.

Overrides:
setCellRenderer in class Component
Parameters:
cellRenderer - indicate whether this component is currently being used as a cell renderer

setMatte

public void setMatte(Matte matte)
              throws MatteException
Description copied from interface: MatteEnabled
Adds an Matte to the component implementing this interface in order to enable matte compositing. If there is already a Matte assigned to the component, and this Matte is animated, it has to be stopped before any call to this method.

Specified by:
setMatte in interface MatteEnabled
Parameters:
matte - the Matte to be assigned to the component. At any point of time there can only be one matte associated to the component, that's way any matte that has been associated before will be overriden by a call to this method. The Matte parameter can also be null, in this case there is no matte associated with the component after the call, even if there had been one before.
Throws:
MatteException - if the Matte has an unsupported type, the platform does not support mattes at all, or an animated matte is associated with the component and is still running
See Also:
MatteEnabled.getMatte()

getMatte

public Matte getMatte()
Description copied from interface: MatteEnabled
Return the Matte currently associated with the component implementing this interface.

Specified by:
getMatte in interface MatteEnabled
Returns:
the Matte currently associated with the component or null if there is none
See Also:
MatteEnabled.setMatte(com.sun.dtv.ui.Matte)

scrollComponentToVisible

protected void scrollComponentToVisible(Component c)
Makes sure the component is visible in the scroll if this container is scrollable

Parameters:
c - the component that will be scrolling for visibility

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.