Adds the specified component to this container at the specified
index. This method also notifies the layout manager to add
the component to this container's layout using the specified
constraints object via the addLayoutComponent
method.
The constraints are
defined by the particular layout manager being used. For
example, the BorderLayout class defines five
constraints: BorderLayout.NORTH,
BorderLayout.SOUTH, BorderLayout.EAST,
BorderLayout.WEST, and BorderLayout.CENTER.
The GridBagLayout class requires a
GridBagConstraints object. Failure to pass
the correct type of constraints object results in an
IllegalArgumentException.
If the current layout manager implements LayoutManager2, then
LayoutManager2.addLayoutComponent(Component,Object) is invoked on
it. If the current layout manager does not implement
LayoutManager2, and constraints is a String, then
LayoutManager.addLayoutComponent(String,Component) is invoked on it.
If the component is not an ancestor of this container and has a non-null parent, it is removed from its current parent before it is added to this container.
This is the method to override if a program needs to track every add request to a container as all other add methods defer to this one. An overriding method should usually include a call to the superclass's version of the method:
super.addImpl(comp, constraints, index)
This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
comp | the component to be added | |
constraints | an object expressing layout constraints for this component | |
index | the position in the container's list at which to
insert the component, where -1
means append to the end |
Gets the AccessibleContext associated with this JLayeredPane. For layered panes, the AccessibleContext takes the form of an AccessibleJLayeredPane. A new AccessibleJLayeredPane instance is created if necessary.
Returns false if components in the pane can overlap, which makes optimized drawing impossible. Otherwise, returns true.
JComponent.isOptimizedDrawingEnabled
Paints this JLayeredPane within the specified graphics context.
g | the Graphics context within which to paint |
Returns a string representation of this JLayeredPane. This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null.
Remove the indexed component from this pane. This is the absolute index, ignoring layers.
index | an int specifying the component to remove |
getIndexOf
Diagram: Layers