java.awt
Class Container

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
BasicSplitPaneDivider, CellRendererPane, DefaultTreeCellEditor.EditorContainer, JComponent, Panel, ScrollPane, Window

public class Container
extends Component

A generic window toolkit object that acts as a container for other objects. Components are tracked in a list, and new elements are at the end of the list or bottom of the stacking order.

Since:
1.0
See Also:
Serialized Form

Nested Class Summary
protected  class Container.AccessibleAWTContainer
          This class provides accessibility support for subclasses of container.
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Container()
          Default constructor for subclasses.
 
Method Summary
 Component add(Component comp)
          Adds the specified component to this container at the end of the component list.
 Component add(Component comp, int index)
          Adds the specified component to this container at the specified index in the component list.
 void add(Component comp, Object constraints)
          Adds the specified component to this container at the end of the component list.
 void add(Component comp, Object constraints, int index)
          Adds the specified component to this container at the specified index in the component list.
 Component add(String name, Component comp)
          Adds the specified component to the container at the end of the component list.
 void addContainerListener(ContainerListener listener)
          Adds the specified container listener to this object's list of container listeners.
protected  void addImpl(Component comp, Object constraints, int index)
          This method is called by all the add() methods to perform the actual adding of the component.
 void addNotify()
          Called when this container is added to another container to inform it to create its peer.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the specified property listener to this component.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds the specified property listener to this component.
 void applyComponentOrientation(ComponentOrientation orientation)
          Sets the ComponentOrientation property of this container and all components contained within it.
 boolean areFocusTraversalKeysSet(int id)
          Returns whether the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Container.
 int countComponents()
          Deprecated. use getComponentCount() instead
 void deliverEvent(Event e)
          Deprecated. use Component.dispatchEvent(AWTEvent) instead
 void doLayout()
          Layout the components in this container.
 Component findComponentAt(int x, int y)
          Locates the visible child component that contains the specified position.
 Component findComponentAt(Point p)
          Locates the visible child component that contains the specified position.
 float getAlignmentX()
          Returns the preferred alignment along the X axis.
 float getAlignmentY()
          Returns the preferred alignment along the Y axis.
 Component getComponent(int n)
          Returns the component at the specified index.
 Component getComponentAt(int x, int y)
          Returns the component located at the specified point.
 Component getComponentAt(Point p)
          Returns the component located at the specified point.
 int getComponentCount()
          Returns the number of components in this container.
 Component[] getComponents()
          Returns an array of the components in this container.
 int getComponentZOrder(Component comp)
          Returns the Z ordering index of comp.
 ContainerListener[] getContainerListeners()
           
 Set<AWTKeyStroke> getFocusTraversalKeys(int id)
          Returns the Set of focus traversal keys for a given traversal operation for this Container.
 FocusTraversalPolicy getFocusTraversalPolicy()
          Return the focus traversal policy that determines the focus traversal order for this Container's children.
 Insets getInsets()
          Returns the insets for this container, which is the space used for borders, the margin, etc.
 LayoutManager getLayout()
          Returns the current layout manager for this container.
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
          Returns all registered EventListeners of the given listenerType.
 Dimension getMaximumSize()
          Returns the maximum size of this container.
 Dimension getMinimumSize()
          Returns the minimum size of this container.
 Point getMousePosition(boolean allowChildren)
          Returns the mouse pointer position relative to this Container's top-left corner.
 Dimension getPreferredSize()
          Returns the preferred size of this container.
 Insets insets()
          Deprecated. use getInsets() instead
 void invalidate()
          Invalidates this container to indicate that it (and all parent containers) need to be laid out.
 boolean isAncestorOf(Component comp)
          Tests whether or not the specified component is contained within this components subtree.
 boolean isFocusCycleRoot()
          Check whether this Container is a focus cycle root.
 boolean isFocusCycleRoot(Container c)
          Check whether the given Container is the focus cycle root of this Container's focus traversal cycle.
 boolean isFocusTraversalPolicyProvider()
          Set to true if this container provides a focus traversal policy, false when the root container's focus traversal policy should be used.
 boolean isFocusTraversalPolicySet()
          Check whether this Container's focus traversal policy has been explicitly set.
 void layout()
          Deprecated. use doLayout() instead
 void list(PrintStream out, int indent)
          Writes a listing of this container to the specified stream starting at the specified indentation point.
 void list(PrintWriter out, int indent)
          Writes a listing of this container to the specified stream starting at the specified indentation point.
 Component locate(int x, int y)
          Deprecated. use getComponentAt(int, int) instead
 Dimension minimumSize()
          Deprecated. use getMinimumSize() instead
 void paint(Graphics g)
          Paints this container.
 void paintComponents(Graphics g)
          Paints all of the components in this container.
protected  String paramString()
          Returns a string representing the state of this container for debugging purposes.
 Dimension preferredSize()
          Deprecated. use getPreferredSize() instead
 void print(Graphics g)
          Prints this container.
 void printComponents(Graphics g)
          Prints all of the components in this container.
protected  void processContainerEvent(ContainerEvent e)
          Called when a container event occurs if container events are enabled.
protected  void processEvent(AWTEvent e)
          Processes the specified event.
 void remove(Component comp)
          Removes the specified component from this container.
 void remove(int index)
          Removes the component at the specified index from this container.
 void removeAll()
          Removes all components from this container.
 void removeContainerListener(ContainerListener listener)
          Removes the specified container listener from this object's list of container listeners.
 void removeNotify()
          Called when this container is removed from its parent container to inform it to destroy its peer.
 void setComponentZOrder(Component comp, int index)
          Sets the Z ordering for the component comp to index.
 void setFocusCycleRoot(boolean focusCycleRoot)
          Set whether or not this Container is the root of a focus traversal cycle.
 void setFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes)
          Sets the focus traversal keys for a given traversal operation for this Container.
 void setFocusTraversalPolicy(FocusTraversalPolicy policy)
          If this Container is a focus cycle root, set the focus traversal policy that determines the focus traversal order for its children.
 void setFocusTraversalPolicyProvider(boolean b)
          Set to true if this container provides a focus traversal policy, false when the root container's focus traversal policy should be used.
 void setFont(Font f)
          Sets the font for this component to the specified font.
 void setLayout(LayoutManager mgr)
          Sets the layout manager for this container to the specified layout manager.
 void transferFocusDownCycle()
          Transfer focus down one focus traversal cycle.
 void update(Graphics g)
          Updates this container.
 void validate()
          Re-lays out the components in this container.
protected  void validateTree()
          Recursively validates the container tree, recomputing any invalid layouts.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Container

public Container()
Default constructor for subclasses.

Method Detail

getComponentCount

public int getComponentCount()
Returns the number of components in this container.

Returns:
The number of components in this container.

countComponents

public int countComponents()
Deprecated. use getComponentCount() instead

Returns the number of components in this container.

Returns:
The number of components in this container.

getComponent

public Component getComponent(int n)
Returns the component at the specified index.

Parameters:
n - The index of the component to retrieve.
Returns:
The requested component.
Throws:
ArrayIndexOutOfBoundsException - If the specified index is invalid

getComponents

public Component[] getComponents()
Returns an array of the components in this container.

Returns:
The components in this container.

getInsets

public Insets getInsets()
Returns the insets for this container, which is the space used for borders, the margin, etc.

Returns:
The insets for this container.

insets

public Insets insets()
Deprecated. use getInsets() instead

Returns the insets for this container, which is the space used for borders, the margin, etc.

Returns:
The insets for this container.

add

public Component add(Component comp)
Adds the specified component to this container at the end of the component list.

Parameters:
comp - The component to add to the container.
Returns:
The same component that was added.

add

public Component add(String name,
                     Component comp)
Adds the specified component to the container at the end of the component list. This method should not be used. Instead, use add(Component, Object).

Parameters:
name - The name of the component to be added.
comp - The component to be added.
Returns:
The same component that was added.
See Also:
add(Component,Object)

add

public Component add(Component comp,
                     int index)
Adds the specified component to this container at the specified index in the component list.

Parameters:
comp - The component to be added.
index - The index in the component list to insert this child at, or -1 to add at the end of the list.
Returns:
The same component that was added.
Throws:
ArrayIndexOutOfBoundsException - If the specified index is invalid.

add

public void add(Component comp,
                Object constraints)
Adds the specified component to this container at the end of the component list. The layout manager will use the specified constraints when laying out this component.

Parameters:
comp - The component to be added to this container.
constraints - The layout constraints for this component.

add

public void add(Component comp,
                Object constraints,
                int index)
Adds the specified component to this container at the specified index in the component list. The layout manager will use the specified constraints when layout out this component.

Parameters:
comp - The component to be added.
constraints - The layout constraints for this component.
index - The index in the component list to insert this child at, or -1 to add at the end of the list.
Throws:
ArrayIndexOutOfBoundsException - If the specified index is invalid.

addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
This method is called by all the add() methods to perform the actual adding of the component. Subclasses who wish to perform their own processing when a component is added should override this method. Any subclass doing this must call the superclass version of this method in order to ensure proper functioning of the container.

Parameters:
comp - The component to be added.
constraints - The layout constraints for this component, or null if there are no constraints.
index - The index in the component list to insert this child at, or -1 to add at the end of the list.
Throws:
ArrayIndexOutOfBoundsException - If the specified index is invalid.

remove

public void remove(int index)
Removes the component at the specified index from this container.

Parameters:
index - The index of the component to remove.

remove

public void remove(Component comp)
Removes the specified component from this container.

Parameters:
comp - The component to remove from this container.

removeAll

public void removeAll()
Removes all components from this container.


getLayout

public LayoutManager getLayout()
Returns the current layout manager for this container.

Returns:
The layout manager for this container.

setLayout

public void setLayout(LayoutManager mgr)
Sets the layout manager for this container to the specified layout manager.

Parameters:
mgr - The new layout manager for this container.

doLayout

public void doLayout()
Layout the components in this container.

Overrides:
doLayout in class Component
See Also:
Component.validate(), LayoutManager

layout

public void layout()
Deprecated. use doLayout() instead

Layout the components in this container.

Overrides:
layout in class Component

invalidate

public void invalidate()
Invalidates this container to indicate that it (and all parent containers) need to be laid out.

Overrides:
invalidate in class Component

validate

public void validate()
Re-lays out the components in this container.

Overrides:
validate in class Component
See Also:
Component.invalidate(), Component.doLayout(), LayoutManager, validate()

validateTree

protected void validateTree()
Recursively validates the container tree, recomputing any invalid layouts.


setFont

public void setFont(Font f)
Description copied from class: Component
Sets the font for this component to the specified font. This is a bound property.

Overrides:
setFont in class Component
Parameters:
f - the new font for this component
See Also:
Component.getFont()

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of this container.

Overrides:
getPreferredSize in class Component
Returns:
The preferred size of this container.
See Also:
Component.getMinimumSize(), Component.setPreferredSize(Dimension), LayoutManager

preferredSize

public Dimension preferredSize()
Deprecated. use getPreferredSize() instead

Returns the preferred size of this container.

Overrides:
preferredSize in class Component
Returns:
The preferred size of this container.

getMinimumSize

public Dimension getMinimumSize()
Returns the minimum size of this container.

Overrides:
getMinimumSize in class Component
Returns:
The minimum size of this container.
See Also:
Component.getPreferredSize(), Component.setMinimumSize(Dimension), LayoutManager

minimumSize

public Dimension minimumSize()
Deprecated. use getMinimumSize() instead

Returns the minimum size of this container.

Overrides:
minimumSize in class Component
Returns:
The minimum size of this container.

getMaximumSize

public Dimension getMaximumSize()
Returns the maximum size of this container.

Overrides:
getMaximumSize in class Component
Returns:
The maximum size of this container.
See Also:
Component.getMinimumSize(), Component.setMaximumSize(Dimension), Component.getPreferredSize(), LayoutManager

getAlignmentX

public float getAlignmentX()
Returns the preferred alignment along the X axis. This is a value between 0 and 1 where 0 represents alignment flush left and 1 means alignment flush right, and 0.5 means centered.

Overrides:
getAlignmentX in class Component
Returns:
The preferred alignment along the X axis.

getAlignmentY

public float getAlignmentY()
Returns the preferred alignment along the Y axis. This is a value between 0 and 1 where 0 represents alignment flush top and 1 means alignment flush bottom, and 0.5 means centered.

Overrides:
getAlignmentY in class Component
Returns:
The preferred alignment along the Y axis.

paint

public void paint(Graphics g)
Paints this container. The implementation of this method in this class forwards to any lightweight components in this container. If this method is subclassed, this method should still be invoked as a superclass method so that lightweight components are properly drawn.

Overrides:
paint in class Component
Parameters:
g - - The graphics context for this paint job.
See Also:
Component.update(Graphics)

update

public void update(Graphics g)
Updates this container. The implementation of this method in this class forwards to any lightweight components in this container. If this method is subclassed, this method should still be invoked as a superclass method so that lightweight components are properly drawn.

Overrides:
update in class Component
Parameters:
g - The graphics context for this update.
See Also:
Component.paint(Graphics), Component.repaint()

print

public void print(Graphics g)
Prints this container. The implementation of this method in this class forwards to any lightweight components in this container. If this method is subclassed, this method should still be invoked as a superclass method so that lightweight components are properly drawn.

Overrides:
print in class Component
Parameters:
g - The graphics context for this print job.
See Also:
Component.paint(Graphics)

paintComponents

public void paintComponents(Graphics g)
Paints all of the components in this container.

Parameters:
g - The graphics context for this paint job.

printComponents

public void printComponents(Graphics g)
Prints all of the components in this container.

Parameters:
g - The graphics context for this print job.

addContainerListener

public void addContainerListener(ContainerListener listener)
Adds the specified container listener to this object's list of container listeners.

Parameters:
listener - The listener to add.

removeContainerListener

public void removeContainerListener(ContainerListener listener)
Removes the specified container listener from this object's list of container listeners.

Parameters:
listener - The listener to remove.

getContainerListeners

public ContainerListener[] getContainerListeners()
Since:
1.4

getListeners

public <T extends EventListener> T[] getListeners(Class<T> listenerType)
Returns all registered EventListeners of the given listenerType.

Overrides:
getListeners in class Component
Parameters:
listenerType - the class of listeners to filter (null not permitted).
Returns:
An array of registered listeners.
Throws:
ClassCastException - if listenerType does not implement the EventListener interface.
NullPointerException - if listenerType is null.
Since:
1.3
See Also:
getContainerListeners()

processEvent

protected void processEvent(AWTEvent e)
Processes the specified event. This method calls processContainerEvent() if this method is a ContainerEvent, otherwise it calls the superclass method.

Overrides:
processEvent in class Component
Parameters:
e - The event to be processed.
See Also:
Component.processComponentEvent(ComponentEvent), Component.processFocusEvent(FocusEvent), Component.processKeyEvent(KeyEvent), Component.processMouseEvent(MouseEvent), Component.processMouseMotionEvent(MouseEvent), Component.processInputMethodEvent(InputMethodEvent), Component.processHierarchyEvent(HierarchyEvent), Component.processMouseWheelEvent(MouseWheelEvent)

processContainerEvent

protected void processContainerEvent(ContainerEvent e)
Called when a container event occurs if container events are enabled. This method calls any registered listeners.

Parameters:
e - The event that occurred.

deliverEvent

public void deliverEvent(Event e)
Deprecated. use Component.dispatchEvent(AWTEvent) instead

AWT 1.0 event processor.

Overrides:
deliverEvent in class Component
Parameters:
e - The event that occurred.

getComponentAt

public Component getComponentAt(int x,
                                int y)
Returns the component located at the specified point. This is done by checking whether or not a child component claims to contain this point. The first child component that does is returned. If no child component claims the point, the container itself is returned, unless the point does not exist within this container, in which case null is returned. When components overlap, the first component is returned. The component that is closest to (x, y), containing that location, is returned. Heavyweight components take precedence of lightweight components. This function does not ignore invisible components. If there is an invisible component at (x,y), it will be returned.

Overrides:
getComponentAt in class Component
Parameters:
x - The X coordinate of the point.
y - The Y coordinate of the point.
Returns:
The component containing the specified point, or null if there is no such point.
See Also:
Component.contains(int, int)

getMousePosition

public Point getMousePosition(boolean allowChildren)
                       throws HeadlessException
Returns the mouse pointer position relative to this Container's top-left corner. If allowChildren is false, the mouse pointer must be directly over this container. If allowChildren is true, the mouse pointer may be over this container or any of its descendents.

Parameters:
allowChildren - true to allow descendents, false if pointer must be directly over Container.
Returns:
relative mouse pointer position
Throws:
HeadlessException - if in a headless environment

locate

public Component locate(int x,
                        int y)
Deprecated. use getComponentAt(int, int) instead

Returns the component located at the specified point. This is done by checking whether or not a child component claims to contain this point. The first child component that does is returned. If no child component claims the point, the container itself is returned, unless the point does not exist within this container, in which case null is returned. When components overlap, the first component is returned. The component that is closest to (x, y), containing that location, is returned. Heavyweight components take precedence of lightweight components. This function does not ignore invisible components. If there is an invisible component at (x,y), it will be returned.

Overrides:
locate in class Component
Parameters:
x - The x position of the point to return the component at.
y - The y position of the point to return the component at.
Returns:
The component containing the specified point, or null if there is no such point.

getComponentAt

public Component getComponentAt(Point p)
Returns the component located at the specified point. This is done by checking whether or not a child component claims to contain this point. The first child component that does is returned. If no child component claims the point, the container itself is returned, unless the point does not exist within this container, in which case null is returned. The top-most child component is returned in the case where components overlap. This is determined by finding the component closest to (x,y) and contains that location. Heavyweight components take precedence of lightweight components. This function does not ignore invisible components. If there is an invisible component at (x,y), it will be returned.

Overrides:
getComponentAt in class Component
Parameters:
p - The point to return the component at.
Returns:
The component containing the specified point, or null if there is no such point.
See Also:
Component.contains(Point)

findComponentAt

public Component findComponentAt(int x,
                                 int y)
Locates the visible child component that contains the specified position. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search. findComponentAt differs from getComponentAt, because it recursively searches a Container's children.

Parameters:
x - - x coordinate
y - - y coordinate
Returns:
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.

findComponentAt

public Component findComponentAt(Point p)
Locates the visible child component that contains the specified position. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search. findComponentAt differs from getComponentAt, because it recursively searches a Container's children.

Parameters:
p - - the component's location
Returns:
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.

addNotify

public void addNotify()
Called when this container is added to another container to inform it to create its peer. Peers for any child components will also be created.

Overrides:
addNotify in class Component
See Also:
Component.isDisplayable(), Component.removeNotify()

removeNotify

public void removeNotify()
Called when this container is removed from its parent container to inform it to destroy its peer. This causes the peers of all child component to be destroyed as well.

Overrides:
removeNotify in class Component
See Also:
Component.isDisplayable(), Component.addNotify()

isAncestorOf

public boolean isAncestorOf(Component comp)
Tests whether or not the specified component is contained within this components subtree.

Parameters:
comp - The component to test.
Returns:
true if this container is an ancestor of the specified component, false otherwise.

paramString

protected String paramString()
Returns a string representing the state of this container for debugging purposes.

Overrides:
paramString in class Component
Returns:
A string representing the state of this container.

list

public void list(PrintStream out,
                 int indent)
Writes a listing of this container to the specified stream starting at the specified indentation point.

Overrides:
list in class Component
Parameters:
out - The PrintStream to write to.
indent - The indentation point.

list

public void list(PrintWriter out,
                 int indent)
Writes a listing of this container to the specified stream starting at the specified indentation point.

Overrides:
list in class Component
Parameters:
out - The PrintWriter to write to.
indent - The indentation point.

setFocusTraversalKeys

public void setFocusTraversalKeys(int id,
                                  Set<? extends AWTKeyStroke> keystrokes)
Sets the focus traversal keys for a given traversal operation for this Container.

Overrides:
setFocusTraversalKeys in class Component
Parameters:
id - one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or UP_CYCLE_TRAVERSAL_KEYS
keystrokes - a set of keys, or null
Throws:
IllegalArgumentException - If id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS, or if keystrokes contains null, or if any Object in keystrokes is not an AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, or if any keystroke already maps to another focus traversal operation for this Container.
Since:
1.4
See Also:
Component.getFocusTraversalKeys(int), KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS

getFocusTraversalKeys

public Set<AWTKeyStroke> getFocusTraversalKeys(int id)
Returns the Set of focus traversal keys for a given traversal operation for this Container.

Overrides:
getFocusTraversalKeys in class Component
Parameters:
id - one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or UP_CYCLE_TRAVERSAL_KEYS
Returns:
set of traversal keys
Throws:
IllegalArgumentException - If id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS.
Since:
1.4
See Also:
(int, Set), KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS

areFocusTraversalKeysSet

public boolean areFocusTraversalKeysSet(int id)
Returns whether the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Container. If this method returns false, this Container is inheriting the Set from an ancestor, or from the current KeyboardFocusManager.

Overrides:
areFocusTraversalKeysSet in class Component
Parameters:
id - one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or UP_CYCLE_TRAVERSAL_KEYS
Returns:
true if that set is explicitly specified
Throws:
IllegalArgumentException - If id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS.
Since:
1.4
See Also:
(int), KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS

isFocusCycleRoot

public boolean isFocusCycleRoot(Container c)
Check whether the given Container is the focus cycle root of this Container's focus traversal cycle. If this Container is a focus cycle root itself, then it will be in two different focus cycles -- it's own, and that of its ancestor focus cycle root's. In that case, if c is either of those containers, this method will return true.

Overrides:
isFocusCycleRoot in class Component
Parameters:
c - the candidate Container
Returns:
true if c is the focus cycle root of the focus traversal cycle to which this Container belongs, false otherwise
Since:
1.4

setFocusTraversalPolicy

public void setFocusTraversalPolicy(FocusTraversalPolicy policy)
If this Container is a focus cycle root, set the focus traversal policy that determines the focus traversal order for its children. If non-null, this policy will be inherited by all inferior focus cycle roots. If policy is null, this Container will inherit its policy from the closest ancestor focus cycle root that's had its policy set.

Parameters:
policy - the new focus traversal policy for this Container or null
Since:
1.4

getFocusTraversalPolicy

public FocusTraversalPolicy getFocusTraversalPolicy()
Return the focus traversal policy that determines the focus traversal order for this Container's children. This method returns null if this Container is not a focus cycle root. If the focus traversal policy has not been set explicitly, then this method will return an ancestor focus cycle root's policy instead.

Returns:
this Container's focus traversal policy or null
Since:
1.4

isFocusTraversalPolicySet

public boolean isFocusTraversalPolicySet()
Check whether this Container's focus traversal policy has been explicitly set. If it has not, then this Container will inherit its focus traversal policy from one of its ancestor focus cycle roots.

Returns:
true if focus traversal policy is set, false otherwise

setFocusCycleRoot

public void setFocusCycleRoot(boolean focusCycleRoot)
Set whether or not this Container is the root of a focus traversal cycle. This Container's focus traversal policy determines the order of focus traversal. Some policies prevent the focus from being transferred between two traversal cycles until an up or down traversal operation is performed. In that case, normal traversal (not up or down) is limited to this Container and all of this Container's descendents that are not descendents of inferior focus cycle roots. In the default case however, ContainerOrderFocusTraversalPolicy is in effect, and it supports implicit down-cycle traversal operations.

Parameters:
focusCycleRoot - true if this is a focus cycle root, false otherwise
Since:
1.4

isFocusTraversalPolicyProvider

public final boolean isFocusTraversalPolicyProvider()
Set to true if this container provides a focus traversal policy, false when the root container's focus traversal policy should be used.

Returns:
true if this container provides a focus traversal policy, false when the root container's focus traversal policy should be used
Since:
1.5
See Also:
setFocusTraversalPolicyProvider(boolean)

setFocusTraversalPolicyProvider

public final void setFocusTraversalPolicyProvider(boolean b)
Set to true if this container provides a focus traversal policy, false when the root container's focus traversal policy should be used.

Parameters:
b - true if this container provides a focus traversal policy, false when the root container's focus traversal policy should be used
Since:
1.5
See Also:
isFocusTraversalPolicyProvider()

isFocusCycleRoot

public boolean isFocusCycleRoot()
Check whether this Container is a focus cycle root.

Returns:
true if this is a focus cycle root, false otherwise
Since:
1.4

transferFocusDownCycle

public void transferFocusDownCycle()
Transfer focus down one focus traversal cycle. If this Container is a focus cycle root, then its default component becomes the focus owner, and this Container becomes the current focus cycle root. No traversal will occur if this Container is not a focus cycle root.

Since:
1.4

applyComponentOrientation

public void applyComponentOrientation(ComponentOrientation orientation)
Sets the ComponentOrientation property of this container and all components contained within it.

Overrides:
applyComponentOrientation in class Component
Parameters:
orientation - the new orientation
Throws:
NullPointerException - If orientation is null
Since:
1.4
See Also:
Component.getComponentOrientation()

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from class: Component
Adds the specified property listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice. The property listener ignores inherited properties. Recognized properties include:

Overrides:
addPropertyChangeListener in class Component
Parameters:
listener - the new listener to add
See Also:
Component.removePropertyChangeListener(PropertyChangeListener), Component.getPropertyChangeListeners(), Component.addPropertyChangeListener(String, PropertyChangeListener)

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Description copied from class: Component
Adds the specified property listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice. The property listener ignores inherited properties. The listener is keyed to a single property. Recognized properties include:

Overrides:
addPropertyChangeListener in class Component
Parameters:
propertyName - the property name to filter on
listener - the new listener to add
See Also:
Component.removePropertyChangeListener(String, PropertyChangeListener), Component.getPropertyChangeListeners(String), Component.addPropertyChangeListener(PropertyChangeListener)

setComponentZOrder

public final void setComponentZOrder(Component comp,
                                     int index)
Sets the Z ordering for the component comp to index. Components with lower Z order paint above components with higher Z order.

Parameters:
comp - the component for which to change the Z ordering
index - the index to set
Throws:
NullPointerException - if comp == null
IllegalArgumentException - if comp is an ancestor of this container
IllegalArgumentException - if index is not in [0, getComponentCount()] for moving between containers or [0, getComponentCount() - 1] for moving inside this container
IllegalArgumentException - if comp == this
IllegalArgumentException - if comp is a Window
Since:
1.5
See Also:
getComponentZOrder(Component)

getComponentZOrder

public final int getComponentZOrder(Component comp)
Returns the Z ordering index of comp. If comp is not a child component of this Container, this returns -1.

Parameters:
comp - the component for which to query the Z ordering
Returns:
the Z ordering index of comp or -1 if comp is not a child of this Container
Since:
1.5
See Also:
setComponentZOrder(Component, int)