Methods Summary |
---|
public java.awt.Component | add(java.awt.Component comp)Appends the specified component to the end of this container.
This is a convenience method for {@link #addImpl}.
Note: If a component has been added to a container that
has been displayed, validate must be
called on that container to display the new component.
If multiple components are being added, you can improve
efficiency by calling validate only once,
after all the components have been added.
addImpl(comp, null, -1);
return comp;
|
public java.awt.Component | add(java.lang.String name, java.awt.Component comp)Adds the specified component to this container.
This is a convenience method for {@link #addImpl}.
This method is obsolete as of 1.1. Please use the
method add(Component, Object) instead.
addImpl(comp, name, -1);
return comp;
|
public java.awt.Component | add(java.awt.Component comp, int index)Adds the specified component to this container at the given
position.
This is a convenience method for {@link #addImpl}.
Note: If a component has been added to a container that
has been displayed, validate must be
called on that container to display the new component.
If multiple components are being added, you can improve
efficiency by calling validate only once,
after all the components have been added.
addImpl(comp, null, index);
return comp;
|
public void | add(java.awt.Component comp, java.lang.Object constraints)Adds the specified component to the end of this container.
Also notifies the layout manager to add the component to
this container's layout using the specified constraints object.
This is a convenience method for {@link #addImpl}.
Note: If a component has been added to a container that
has been displayed, validate must be
called on that container to display the new component.
If multiple components are being added, you can improve
efficiency by calling validate only once,
after all the components have been added.
addImpl(comp, constraints, -1);
|
public void | add(java.awt.Component comp, java.lang.Object constraints, int index)Adds the specified component to this container with the specified
constraints at the specified index. Also notifies the layout
manager to add the component to the this container's layout using
the specified constraints object.
This is a convenience method for {@link #addImpl}.
Note: If a component has been added to a container that
has been displayed, validate must be
called on that container to display the new component.
If multiple components are being added, you can improve
efficiency by calling validate only once,
after all the components have been added.
addImpl(comp, constraints, index);
|
public synchronized void | addContainerListener(java.awt.event.ContainerListener l)Adds the specified container listener to receive container events
from this container.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
containerListener = AWTEventMulticaster.add(containerListener, l);
newEventsOnly = true;
|
private void | addDelicately(java.awt.Component comp, java.awt.Container curParent, int index)Adds component to this container. Tries to minimize side effects of this adding -
doesn't call remove notify if it is not required.
checkTreeLock();
// Check if moving between containers
if (curParent != this) {
/* Add component to list; allocate new array if necessary. */
if (ncomponents == component.length) {
Component newcomponents[] = new Component[ncomponents * 2 + 1];
System.arraycopy(component, 0, newcomponents, 0, ncomponents);
component = newcomponents;
}
if (index == -1 || index == ncomponents) {
component[ncomponents++] = comp;
} else {
System.arraycopy(component, index, component,
index + 1, ncomponents - index);
component[index] = comp;
ncomponents++;
}
comp.parent = this;
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
adjustDescendants(comp.countHierarchyMembers());
} else {
if (index < ncomponents) {
component[index] = comp;
}
}
if (valid) {
invalidate();
}
if (peer != null) {
if (comp.peer == null) { // Remove notify was called or it didn't have peer - create new one
comp.addNotify();
// New created peer creates component on top of the stacking order
Container newNativeContainer = getHeavyweightContainer();
if (((ContainerPeer)newNativeContainer.getPeer()).isRestackSupported()) {
((ContainerPeer)newNativeContainer.getPeer()).restack();
}
} else { // Both container and child have peers, it means child peer should be reparented.
// In both cases we need to reparent native widgets.
Container newNativeContainer = getHeavyweightContainer();
Container oldNativeContainer = curParent.getHeavyweightContainer();
if (oldNativeContainer != newNativeContainer) {
// Native container changed - need to reparent native widgets
newNativeContainer.reparentChild(comp);
}
// If component still has a peer and it is either container or heavyweight
// and restack is supported we have to restack native windows since order might have changed
if ((!comp.isLightweight() || (comp instanceof Container))
&& ((ContainerPeer)newNativeContainer.getPeer()).isRestackSupported())
{
((ContainerPeer)newNativeContainer.getPeer()).restack();
}
if (!comp.isLightweight() && isLightweight()) {
// If component is heavyweight and one of the containers is lightweight
// some NativeInLightFixer activity should be performed
if (!curParent.isLightweight()) {
// Moving from heavyweight container to lightweight container - should create NativeInLightFixer
// since addNotify does this
comp.nativeInLightFixer = new NativeInLightFixer();
} else {
// Component already has NativeInLightFixer - just reinstall it
// because hierarchy changed and he needs to rebuild list of parents to listen.
comp.nativeInLightFixer.install(this);
}
}
}
}
if (curParent != this) {
/* Notify the layout manager of the added component. */
if (layoutMgr != null) {
if (layoutMgr instanceof LayoutManager2) {
((LayoutManager2)layoutMgr).addLayoutComponent(comp, null);
} else {
layoutMgr.addLayoutComponent(null, comp);
}
}
if (containerListener != null ||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
ContainerEvent e = new ContainerEvent(this,
ContainerEvent.COMPONENT_ADDED,
comp);
dispatchEvent(e);
}
comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
this, HierarchyEvent.PARENT_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
// If component is focus owner or parent container of focus owner check that after reparenting
// focus owner moved out if new container prohibit this kind of focus owner.
if (comp.isFocusOwner() && !comp.canBeFocusOwner()) {
comp.transferFocus();
} else if (comp instanceof Container) {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner != null && isParentOf(focusOwner) && !focusOwner.canBeFocusOwner()) {
focusOwner.transferFocus();
}
}
} else {
comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
this, HierarchyEvent.HIERARCHY_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
}
if (peer != null && layoutMgr == null && isVisible()) {
updateCursorImmediately();
}
|
protected void | addImpl(java.awt.Component comp, java.lang.Object constraints, int index)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 layout manager implements both the LayoutManager
and LayoutManager2 interfaces, the
LayoutManager2 methods are called.
Note that if the component already exists
in this container or a child of this container,
it is removed from that container before
being 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)
synchronized (getTreeLock()) {
/* Check for correct arguments: index in bounds,
* comp cannot be one of this container's parents,
* and comp cannot be a window.
* comp and container must be on the same GraphicsDevice.
* if comp is container, all sub-components must be on
* same GraphicsDevice.
*/
GraphicsConfiguration thisGC = this.getGraphicsConfiguration();
if (index > ncomponents || (index < 0 && index != -1)) {
throw new IllegalArgumentException(
"illegal component position");
}
if (comp instanceof Container) {
for (Container cn = this; cn != null; cn=cn.parent) {
if (cn == comp) {
throw new IllegalArgumentException(
"adding container's parent to itself");
}
}
if (comp instanceof Window) {
throw new IllegalArgumentException(
"adding a window to a container");
}
}
if (thisGC != null) {
comp.checkGD(thisGC.getDevice().getIDstring());
}
/* Reparent the component and tidy up the tree's state. */
if (comp.parent != null) {
comp.parent.remove(comp);
if (index > ncomponents) {
throw new IllegalArgumentException("illegal component position");
}
}
/* Add component to list; allocate new array if necessary. */
if (ncomponents == component.length) {
Component newcomponents[] = new Component[ncomponents * 2 + 1];
System.arraycopy(component, 0, newcomponents, 0, ncomponents);
component = newcomponents;
}
if (index == -1 || index == ncomponents) {
component[ncomponents++] = comp;
} else {
System.arraycopy(component, index, component,
index + 1, ncomponents - index);
component[index] = comp;
ncomponents++;
}
comp.parent = this;
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
adjustDescendants(comp.countHierarchyMembers());
if (valid) {
invalidate();
}
if (peer != null) {
comp.addNotify();
}
/* Notify the layout manager of the added component. */
if (layoutMgr != null) {
if (layoutMgr instanceof LayoutManager2) {
((LayoutManager2)layoutMgr).addLayoutComponent(comp, constraints);
} else if (constraints instanceof String) {
layoutMgr.addLayoutComponent((String)constraints, comp);
}
}
if (containerListener != null ||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
ContainerEvent e = new ContainerEvent(this,
ContainerEvent.COMPONENT_ADDED,
comp);
dispatchEvent(e);
}
comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
this, HierarchyEvent.PARENT_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
if (peer != null && layoutMgr == null && isVisible()) {
updateCursorImmediately();
}
}
|
public void | addNotify()Makes this Container displayable by connecting it to
a native screen resource. Making a container displayable will
cause all of its children to be made displayable.
This method is called internally by the toolkit and should
not be called directly by programs.
synchronized (getTreeLock()) {
// addNotify() on the children may cause proxy event enabling
// on this instance, so we first call super.addNotify() and
// possibly create an lightweight event dispatcher before calling
// addNotify() on the children which may be lightweight.
super.addNotify();
if (! (peer instanceof LightweightPeer)) {
dispatcher = new LightweightDispatcher(this);
}
int ncomponents = this.ncomponents;
Component component[] = this.component;
for (int i = 0 ; i < ncomponents ; i++) {
component[i].addNotify();
}
// Update stacking order if native platform allows
ContainerPeer cpeer = (ContainerPeer)peer;
if (cpeer.isRestackSupported()) {
cpeer.restack();
}
}
|
public void | addPropertyChangeListener(java.beans.PropertyChangeListener listener)Adds a PropertyChangeListener to the listener list. The listener is
registered for all bound properties of this class, including the
following:
- this Container's font ("font")
- this Container's background color ("background")
- this Container's foreground color ("foreground")
- this Container's focusability ("focusable")
- this Container's focus traversal keys enabled state
("focusTraversalKeysEnabled")
- this Container's Set of FORWARD_TRAVERSAL_KEYS
("forwardFocusTraversalKeys")
- this Container's Set of BACKWARD_TRAVERSAL_KEYS
("backwardFocusTraversalKeys")
- this Container's Set of UP_CYCLE_TRAVERSAL_KEYS
("upCycleFocusTraversalKeys")
- this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS
("downCycleFocusTraversalKeys")
- this Container's focus traversal policy ("focusTraversalPolicy")
- this Container's focus-cycle-root state ("focusCycleRoot")
Note that if this Container is inheriting a bound property, then no
event will be fired in response to a change in the inherited property.
If listener is null, no exception is thrown and no action is performed.
super.addPropertyChangeListener(listener);
|
public void | addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Adds a PropertyChangeListener to the listener list for a specific
property. The specified property may be user-defined, or one of the
following defaults:
- this Container's font ("font")
- this Container's background color ("background")
- this Container's foreground color ("foreground")
- this Container's focusability ("focusable")
- this Container's focus traversal keys enabled state
("focusTraversalKeysEnabled")
- this Container's Set of FORWARD_TRAVERSAL_KEYS
("forwardFocusTraversalKeys")
- this Container's Set of BACKWARD_TRAVERSAL_KEYS
("backwardFocusTraversalKeys")
- this Container's Set of UP_CYCLE_TRAVERSAL_KEYS
("upCycleFocusTraversalKeys")
- this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS
("downCycleFocusTraversalKeys")
- this Container's focus traversal policy ("focusTraversalPolicy")
- this Container's focus-cycle-root state ("focusCycleRoot")
- this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")
- this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")
Note that if this Container is inheriting a bound property, then no
event will be fired in response to a change in the inherited property.
If listener is null, no exception is thrown and no action is performed.
super.addPropertyChangeListener(propertyName, listener);
|
void | adjustDecendantsOnParent(int num)
if (parent != null) {
parent.adjustDescendants(num);
}
|
void | adjustDescendants(int num)
if (num == 0)
return;
descendantsCount += num;
adjustDecendantsOnParent(num);
|
void | adjustListeningChildren(long mask, int num)
if (dbg.on) {
dbg.assertion(mask == AWTEvent.HIERARCHY_EVENT_MASK ||
mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK ||
mask == (AWTEvent.HIERARCHY_EVENT_MASK |
AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
}
if (num == 0)
return;
if ((mask & AWTEvent.HIERARCHY_EVENT_MASK) != 0) {
listeningChildren += num;
}
if ((mask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0) {
listeningBoundsChildren += num;
}
adjustListeningChildrenOnParent(mask, num);
|
public void | applyComponentOrientation(java.awt.ComponentOrientation o)Sets the ComponentOrientation property of this container
and all components contained within it.
super.applyComponentOrientation(o);
for (int i = 0 ; i < ncomponents ; ++i) {
component[i].applyComponentOrientation(o);
}
|
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.
if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) {
throw new IllegalArgumentException("invalid focus traversal key identifier");
}
return (focusTraversalKeys != null && focusTraversalKeys[id] != null);
|
boolean | canContainFocusOwner(java.awt.Component focusOwnerCandidate)Checks whether this container can contain component which is focus owner.
Verifies that container is enable and showing, and if it is focus cycle root
its FTP allows component to be focus owner
if (!(isEnabled() && isDisplayable()
&& isVisible() && isFocusable()))
{
return false;
}
if (isFocusCycleRoot()) {
FocusTraversalPolicy policy = getFocusTraversalPolicy();
if (policy instanceof DefaultFocusTraversalPolicy) {
if (!((DefaultFocusTraversalPolicy)policy).accept(focusOwnerCandidate)) {
return false;
}
}
}
synchronized(getTreeLock()) {
if (parent != null) {
return parent.canContainFocusOwner(focusOwnerCandidate);
}
}
return true;
|
private void | checkAdding(java.awt.Component comp, int index)Checks that the component comp can be added to this container
Checks : index in bounds of container's size,
comp is not one of this container's parents,
and comp is not a window.
Comp and container must be on the same GraphicsDevice.
if comp is container, all sub-components must be on
same GraphicsDevice.
checkTreeLock();
GraphicsConfiguration thisGC = getGraphicsConfiguration();
if (index > ncomponents || index < 0) {
throw new IllegalArgumentException("illegal component position");
}
if (comp.parent == this) {
if (index == ncomponents) {
throw new IllegalArgumentException("illegal component position " +
index + " should be less then " + ncomponents);
}
}
if (comp instanceof Container) {
for (Container cn = this; cn != null; cn=cn.parent) {
if (cn == comp) {
throw new IllegalArgumentException("adding container's parent to itself");
}
}
if (comp instanceof Window) {
throw new IllegalArgumentException("adding a window to a container");
}
}
Window thisTopLevel = getContainingWindow();
Window compTopLevel = comp.getContainingWindow();
if (thisTopLevel != compTopLevel) {
throw new IllegalArgumentException("component and container should be in the same top-level window");
}
if (thisGC != null) {
comp.checkGD(thisGC.getDevice().getIDstring());
}
|
void | checkGD(java.lang.String stringID)Checks that all Components that this Container contains are on
the same GraphicsDevice as this Container. If not, throws an
IllegalArgumentException.
Component tempComp;
for (int i = 0; i < component.length; i++) {
tempComp= component[i];
if (tempComp != null) {
tempComp.checkGD(stringID);
}
}
|
void | checkTreeLock()
if (!Thread.holdsLock(getTreeLock())) {
throw new IllegalStateException("This function should be called while holding treeLock");
}
|
void | clearCurrentFocusCycleRootOnHide()
KeyboardFocusManager kfm =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
Container cont = kfm.getCurrentFocusCycleRoot();
synchronized (getTreeLock()) {
while (this != cont && !(cont instanceof Window) && (cont != null)) {
cont = cont.getParent();
}
}
if (cont == this) {
kfm.setGlobalCurrentFocusCycleRoot(null);
}
|
void | clearMostRecentFocusOwnerOnHide()
Component comp = null;
Container window = this;
synchronized (getTreeLock()) {
while (window != null && !(window instanceof Window)) {
window = window.getParent();
}
if (window != null) {
comp = KeyboardFocusManager.
getMostRecentFocusOwner((Window)window);
while ((comp != null) && (comp != this) && !(comp instanceof Window)) {
comp = comp.getParent();
}
}
}
if (comp == this) {
KeyboardFocusManager.setMostRecentFocusOwner((Window)window, null);
}
if (window != null) {
Window myWindow = (Window)window;
synchronized(getTreeLock()) {
// This synchronized should always be the second in a pair (tree lock, KeyboardFocusManager.class)
synchronized(KeyboardFocusManager.class) {
Component storedComp = myWindow.getTemporaryLostComponent();
if (isParentOf(storedComp) || storedComp == this) {
myWindow.setTemporaryLostComponent(null);
}
}
}
}
|
final boolean | containsFocus()
synchronized (getTreeLock()) {
Component comp = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getFocusOwner();
while (comp != null && !(comp instanceof Window) && comp != this)
{
comp = (Component) comp.getParent();
}
return (comp == this);
}
|
public int | countComponents()
return ncomponents;
|
int | countHierarchyMembers()
if (dbg.on) {
// Verify descendantsCount is correct
int sum = 0;
for (int i = 0; i < ncomponents; i++) {
sum += component[i].countHierarchyMembers();
}
dbg.assertion(descendantsCount == sum);
}
return descendantsCount + 1;
|
final void | createChildHierarchyEvents(int id, long changeFlags, boolean enabledOnToolkit)
assert Thread.holdsLock(getTreeLock());
if (ncomponents == 0) {
return;
}
int listeners = getListenersCount(id, enabledOnToolkit);
for (int count = listeners, i = 0; count > 0; i++) {
count -= component[i].createHierarchyEvents(id, this, parent,
changeFlags, enabledOnToolkit);
}
|
final int | createHierarchyEvents(int id, java.awt.Component changed, java.awt.Container changedParent, long changeFlags, boolean enabledOnToolkit)
assert Thread.holdsLock(getTreeLock());
int listeners = getListenersCount(id, enabledOnToolkit);
for (int count = listeners, i = 0; count > 0; i++) {
count -= component[i].createHierarchyEvents(id, changed,
changedParent, changeFlags, enabledOnToolkit);
}
return listeners +
super.createHierarchyEvents(id, changed, changedParent,
changeFlags, enabledOnToolkit);
|
public void | deliverEvent(java.awt.Event e)
Component comp = getComponentAt(e.x, e.y);
if ((comp != null) && (comp != this)) {
e.translate(-comp.x, -comp.y);
comp.deliverEvent(e);
} else {
postEvent(e);
}
|
void | dispatchEventImpl(java.awt.AWTEvent e)
if ((dispatcher != null) && dispatcher.dispatchEvent(e)) {
// event was sent to a lightweight component. The
// native-produced event sent to the native container
// must be properly disposed of by the peer, so it
// gets forwarded. If the native host has been removed
// as a result of the sending the lightweight event,
// the peer reference will be null.
e.consume();
if (peer != null) {
peer.handleEvent(e);
}
return;
}
super.dispatchEventImpl(e);
synchronized (getTreeLock()) {
switch (e.getID()) {
case ComponentEvent.COMPONENT_RESIZED:
createChildHierarchyEvents(HierarchyEvent.ANCESTOR_RESIZED, 0,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
break;
case ComponentEvent.COMPONENT_MOVED:
createChildHierarchyEvents(HierarchyEvent.ANCESTOR_MOVED, 0,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
break;
default:
break;
}
}
|
void | dispatchEventToSelf(java.awt.AWTEvent e)
super.dispatchEventImpl(e);
|
public void | doLayout()Causes this container to lay out its components. Most programs
should not call this method directly, but should invoke
the validate method instead.
layout();
|
boolean | eventEnabled(java.awt.AWTEvent e)
int id = e.getID();
if (id == ContainerEvent.COMPONENT_ADDED ||
id == ContainerEvent.COMPONENT_REMOVED) {
if ((eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
containerListener != null) {
return true;
}
return false;
}
return super.eventEnabled(e);
|
public java.awt.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.
The findComponentAt method is different from getComponentAt in
that getComponentAt only searches the Container's immediate
children; if the containing component is a Container,
findComponentAt will search that child to find a nested component.
synchronized (getTreeLock()) {
return findComponentAt(x, y, true);
}
|
final java.awt.Component | findComponentAt(int x, int y, boolean ignoreEnabled)Private version of findComponentAt which has a controllable
behavior. Setting 'ignoreEnabled' to 'false' bypasses disabled
Components during the search. This behavior is used by the
lightweight cursor support in sun.awt.GlobalCursorManager.
The cursor code calls this function directly via native code.
The addition of this feature is temporary, pending the
adoption of new, public API which exports this feature.
if (isRecursivelyVisible()){
return findComponentAtImpl(x, y, ignoreEnabled);
}
return null;
|
public java.awt.Component | findComponentAt(java.awt.Point p)Locates the visible child component that contains the specified
point. 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.
The findComponentAt method is different from getComponentAt in
that getComponentAt only searches the Container's immediate
children; if the containing component is a Container,
findComponentAt will search that child to find a nested component.
return findComponentAt(p.x, p.y);
|
final java.awt.Component | findComponentAtImpl(int x, int y, boolean ignoreEnabled)
if (!(contains(x, y) && visible && (ignoreEnabled || enabled))) {
return null;
}
int ncomponents = this.ncomponents;
Component component[] = this.component;
// Two passes: see comment in sun.awt.SunGraphicsCallback
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp != null &&
!(comp.peer instanceof LightweightPeer)) {
if (comp instanceof Container) {
comp = ((Container)comp).findComponentAtImpl(x - comp.x,
y - comp.y,
ignoreEnabled);
} else {
comp = comp.locate(x - comp.x, y - comp.y);
}
if (comp != null && comp.visible &&
(ignoreEnabled || comp.enabled))
{
return comp;
}
}
}
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp != null &&
comp.peer instanceof LightweightPeer) {
if (comp instanceof Container) {
comp = ((Container)comp).findComponentAtImpl(x - comp.x,
y - comp.y,
ignoreEnabled);
} else {
comp = comp.locate(x - comp.x, y - comp.y);
}
if (comp != null && comp.visible &&
(ignoreEnabled || comp.enabled))
{
return comp;
}
}
}
return this;
|
private java.awt.Container | findTraversalRoot()
// I potentially have two roots, myself and my root parent
// If I am the current root, then use me
// If none of my parents are roots, then use me
// If my root parent is the current root, then use my root parent
// If neither I nor my root parent is the current root, then
// use my root parent (a guess)
Container currentFocusCycleRoot = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getCurrentFocusCycleRoot();
Container root;
if (currentFocusCycleRoot == this) {
root = this;
} else {
root = getFocusCycleRootAncestor();
if (root == null) {
root = this;
}
}
if (root != currentFocusCycleRoot) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRoot(root);
}
return root;
|
javax.accessibility.Accessible | getAccessibleAt(java.awt.Point p)Returns the Accessible child contained at the local
coordinate Point , if one exists. Otherwise
returns null .
synchronized (getTreeLock()) {
if (this instanceof Accessible) {
Accessible a = (Accessible)this;
AccessibleContext ac = a.getAccessibleContext();
if (ac != null) {
AccessibleComponent acmp;
Point location;
int nchildren = ac.getAccessibleChildrenCount();
for (int i=0; i < nchildren; i++) {
a = ac.getAccessibleChild(i);
if ((a != null)) {
ac = a.getAccessibleContext();
if (ac != null) {
acmp = ac.getAccessibleComponent();
if ((acmp != null) && (acmp.isShowing())) {
location = acmp.getLocation();
Point np = new Point(p.x-location.x,
p.y-location.y);
if (acmp.contains(np)){
return a;
}
}
}
}
}
}
return (Accessible)this;
} else {
Component ret = this;
if (!this.contains(p.x,p.y)) {
ret = null;
} else {
int ncomponents = this.getComponentCount();
for (int i=0; i < ncomponents; i++) {
Component comp = this.getComponent(i);
if ((comp != null) && comp.isShowing()) {
Point location = comp.getLocation();
if (comp.contains(p.x-location.x,p.y-location.y)) {
ret = comp;
}
}
}
}
if (ret instanceof Accessible) {
return (Accessible) ret;
}
}
return null;
}
|
javax.accessibility.Accessible | getAccessibleChild(int i)Returns the nth Accessible child of the object.
synchronized (getTreeLock()) {
Component[] children = this.getComponents();
int count = 0;
for (int j = 0; j < children.length; j++) {
if (children[j] instanceof Accessible) {
if (count == i) {
return (Accessible) children[j];
} else {
count++;
}
}
}
return null;
}
|
int | getAccessibleChildrenCount()Returns the number of accessible children in the object. If all
of the children of this object implement Accessible ,
then this method should return the number of children of this object.
synchronized (getTreeLock()) {
int count = 0;
Component[] children = this.getComponents();
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof Accessible) {
count++;
}
}
return count;
}
|
public float | getAlignmentX()Returns the alignment along the x axis. This specifies how
the component would like to be aligned relative to other
components. The value should be a number between 0 and 1
where 0 represents alignment along the origin, 1 is aligned
the furthest away from the origin, 0.5 is centered, etc.
float xAlign;
if (layoutMgr instanceof LayoutManager2) {
synchronized (getTreeLock()) {
LayoutManager2 lm = (LayoutManager2) layoutMgr;
xAlign = lm.getLayoutAlignmentX(this);
}
} else {
xAlign = super.getAlignmentX();
}
return xAlign;
|
public float | getAlignmentY()Returns the alignment along the y axis. This specifies how
the component would like to be aligned relative to other
components. The value should be a number between 0 and 1
where 0 represents alignment along the origin, 1 is aligned
the furthest away from the origin, 0.5 is centered, etc.
float yAlign;
if (layoutMgr instanceof LayoutManager2) {
synchronized (getTreeLock()) {
LayoutManager2 lm = (LayoutManager2) layoutMgr;
yAlign = lm.getLayoutAlignmentY(this);
}
} else {
yAlign = super.getAlignmentY();
}
return yAlign;
|
public java.awt.Component | getComponent(int n)Gets the nth component in this container.
synchronized (getTreeLock()) {
if ((n < 0) || (n >= ncomponents)) {
throw new ArrayIndexOutOfBoundsException("No such child: " + n);
}
return component[n];
}
|
public java.awt.Component | getComponentAt(int x, int y)Locates the component that contains the x,y position. The
top-most child component is returned in the case where there
is overlap in the components. This is determined by finding
the component closest to the index 0 that claims to contain
the given point via Component.contains(), except that Components
which have native peers take precedence over those which do not
(i.e., lightweight Components).
return locate(x, y);
|
public java.awt.Component | getComponentAt(java.awt.Point p)Gets the component that contains the specified point.
return getComponentAt(p.x, p.y);
|
public int | getComponentCount()Gets the number of components in this panel.
return countComponents();
|
public final int | getComponentZOrder(java.awt.Component comp)Returns the z-order index of the component inside the container.
The higher a component is in the z-order hierarchy, the lower
its index. The component with the lowest z-order index is
painted last, above all other child components.
if (comp == null) {
return -1;
}
synchronized(getTreeLock()) {
// Quick check - container should be immediate parent of the component
if (comp.parent != this) {
return -1;
}
for (int i = 0; i < ncomponents; i++) {
if (component[i] == comp) {
return i;
}
}
}
// To please javac
return -1;
|
public java.awt.Component[] | getComponents()Gets all the components in this container.
return getComponents_NoClientCode();
|
final java.awt.Component[] | getComponents_NoClientCode()
synchronized (getTreeLock()) {
Component list[] = new Component[ncomponents];
System.arraycopy(component, 0, list, 0, ncomponents);
return list;
}
|
public synchronized java.awt.event.ContainerListener[] | getContainerListeners()Returns an array of all the container listeners
registered on this container.
return (ContainerListener[]) (getListeners(ContainerListener.class));
|
java.awt.Component | getDropTargetEventTarget(int x, int y, boolean includeSelf)Fetches the top-most (deepest) component to receive SunDropTargetEvents.
return getMouseEventTarget(x, y, includeSelf,
DropTargetEventTargetFilter.FILTER,
SEARCH_HEAVYWEIGHTS);
|
public java.util.Set | getFocusTraversalKeys(int id)Returns the Set of focus traversal keys for a given traversal operation
for this Container. (See
setFocusTraversalKeys for a full description of each key.)
If a Set of traversal keys has not been explicitly defined for this
Container, then this Container's parent's Set is returned. If no Set
has been explicitly defined for any of this Container's ancestors, then
the current KeyboardFocusManager's default Set is returned.
if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) {
throw new IllegalArgumentException("invalid focus traversal key identifier");
}
// Don't call super.getFocusTraversalKey. The Component parameter check
// does not allow DOWN_CYCLE_TRAVERSAL_KEY, but we do.
return getFocusTraversalKeys_NoIDCheck(id);
|
public java.awt.FocusTraversalPolicy | getFocusTraversalPolicy()Returns the focus traversal policy that will manage keyboard traversal
of this Container's children, or null if this Container is not a focus
cycle root. If no traversal policy has been explicitly set for this
Container, then this Container's focus-cycle-root ancestor's policy is
returned.
if (!isFocusTraversalPolicyProvider() && !isFocusCycleRoot()) {
return null;
}
FocusTraversalPolicy policy = this.focusTraversalPolicy;
if (policy != null) {
return policy;
}
Container rootAncestor = getFocusCycleRootAncestor();
if (rootAncestor != null) {
return rootAncestor.getFocusTraversalPolicy();
} else {
return KeyboardFocusManager.getCurrentKeyboardFocusManager().
getDefaultFocusTraversalPolicy();
}
|
java.awt.Container | getHeavyweightContainer()Returns closest heavyweight component to this container. If this container is heavyweight
returns this.
checkTreeLock();
if (peer != null && !(peer instanceof LightweightPeer)) {
return this;
} else {
return getNativeContainer();
}
|
public java.awt.Insets | getInsets()Determines the insets of this container, which indicate the size
of the container's border.
A Frame object, for example, has a top inset that
corresponds to the height of the frame's title bar.
return insets();
|
public java.awt.LayoutManager | getLayout()Gets the layout manager for this container.
return layoutMgr;
|
public T[] | getListeners(java.lang.Class listenerType)Returns an array of all the objects currently registered
as FooListener s
upon this Container .
FooListener s are registered using the
addFooListener method.
You can specify the listenerType argument
with a class literal, such as
FooListener.class .
For example, you can query a
Container c
for its container listeners with the following code:
ContainerListener[] cls = (ContainerListener[])(c.getListeners(ContainerListener.class));
If no such listeners exist, this method returns an empty array.
EventListener l = null;
if (listenerType == ContainerListener.class) {
l = containerListener;
} else {
return super.getListeners(listenerType);
}
return AWTEventMulticaster.getListeners(l, listenerType);
|
private int | getListenersCount(int id, boolean enabledOnToolkit)
assert Thread.holdsLock(getTreeLock());
if (enabledOnToolkit) {
return descendantsCount;
}
switch (id) {
case HierarchyEvent.HIERARCHY_CHANGED:
return listeningChildren;
case HierarchyEvent.ANCESTOR_MOVED:
case HierarchyEvent.ANCESTOR_RESIZED:
return listeningBoundsChildren;
default:
return 0;
}
|
public java.awt.Dimension | getMaximumSize()Returns the maximum size of this container.
/* Avoid grabbing the lock if a reasonable cached size value
* is available.
*/
Dimension dim = maxSize;
if (dim == null || !(isMaximumSizeSet() || isValid())) {
synchronized (getTreeLock()) {
if (layoutMgr instanceof LayoutManager2) {
LayoutManager2 lm = (LayoutManager2) layoutMgr;
maxSize = lm.maximumLayoutSize(this);
} else {
maxSize = super.getMaximumSize();
}
dim = maxSize;
}
}
if (dim != null){
return new Dimension(dim);
}
else{
return dim;
}
|
public java.awt.Dimension | getMinimumSize()Returns the minimum size of this container.
return minimumSize();
|
java.awt.Component | getMouseEventTarget(int x, int y, boolean includeSelf)Fetchs the top-most (deepest) lightweight component that is interested
in receiving mouse events.
return getMouseEventTarget(x, y, includeSelf,
MouseEventTargetFilter.FILTER,
!SEARCH_HEAVYWEIGHTS);
|
private java.awt.Component | getMouseEventTarget(int x, int y, boolean includeSelf, java.awt.Container$EventTargetFilter filter, boolean searchHeavyweights)A private version of getMouseEventTarget which has two additional
controllable behaviors. This method searches for the top-most
descendant of this container that contains the given coordinates
and is accepted by the given filter. The search will be constrained to
lightweight descendants if the last argument is false .
Component comp = null;
if (searchHeavyweights) {
comp = getMouseEventTargetImpl(x, y, includeSelf, filter,
SEARCH_HEAVYWEIGHTS,
searchHeavyweights);
}
if (comp == null || comp == this) {
comp = getMouseEventTargetImpl(x, y, includeSelf, filter,
!SEARCH_HEAVYWEIGHTS,
searchHeavyweights);
}
return comp;
|
private java.awt.Component | getMouseEventTargetImpl(int x, int y, boolean includeSelf, java.awt.Container$EventTargetFilter filter, boolean searchHeavyweightChildren, boolean searchHeavyweightDescendants)A private version of getMouseEventTarget which has three additional
controllable behaviors. This method searches for the top-most
descendant of this container that contains the given coordinates
and is accepted by the given filter. The search will be constrained to
descendants of only lightweight children or only heavyweight children
of this container depending on searchHeavyweightChildren. The search will
be constrained to only lightweight descendants of the searched children
of this container if searchHeavyweightDescendants is false .
int ncomponents = this.ncomponents;
Component component[] = this.component;
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp != null && comp.visible &&
((!searchHeavyweightChildren &&
comp.peer instanceof LightweightPeer) ||
(searchHeavyweightChildren &&
!(comp.peer instanceof LightweightPeer))) &&
comp.contains(x - comp.x, y - comp.y)) {
// found a component that intersects the point, see if there is
// a deeper possibility.
if (comp instanceof Container) {
Container child = (Container) comp;
Component deeper = child.getMouseEventTarget(x - child.x,
y - child.y,
includeSelf,
filter,
searchHeavyweightDescendants);
if (deeper != null) {
return deeper;
}
} else {
if (filter.accept(comp)) {
// there isn't a deeper target, but this component is a
// target
return comp;
}
}
}
}
boolean isPeerOK;
boolean isMouseOverMe;
isPeerOK = (peer instanceof LightweightPeer) || includeSelf;
isMouseOverMe = contains(x,y);
// didn't find a child target, return this component if it's a possible
// target
if (isMouseOverMe && isPeerOK && filter.accept(this)) {
return this;
}
// no possible target
return null;
|
public java.awt.Point | getMousePosition(boolean allowChildren)Returns the position of the mouse pointer in this Container 's
coordinate space if the Container is under the mouse pointer,
otherwise returns null .
This method is similar to {@link Component#getMousePosition()} with the exception
that it can take the Container 's children into account.
If allowChildren is false , this method will return
a non-null value only if the mouse pointer is above the Container
directly, not above the part obscured by children.
If allowChildren is true , this method returns
a non-null value if the mouse pointer is above Container or any
of its descendants.
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return MouseInfo.getPointerInfo();
}
}
);
synchronized (getTreeLock()) {
Component inTheSameWindow = findUnderMouseInWindow(pi);
if (isSameOrAncestorOf(inTheSameWindow, allowChildren)) {
return pointRelativeToComponent(pi.getLocation());
}
return null;
}
|
public java.awt.Dimension | getPreferredSize()Returns the preferred size of this container.
return preferredSize();
|
private boolean | hasHeavyweightChildren()Checks whether or not this container has heavyweight children.
Note: Should be called while holding tree lock
checkTreeLock();
boolean res = true; // true while it is lightweight
for (int i = 0; i < getComponentCount() && res; i++) {
Component child = getComponent(i);
res &= child.isLightweight();
if (res && child instanceof Container) {
res &= !((Container)child).hasHeavyweightChildren();
}
}
return !res;
|
private static native void | initIDs()Initialize JNI field and method IDs for fields that may be
called from C.
|
void | initializeFocusTraversalKeys()
focusTraversalKeys = new Set[4];
|
public java.awt.Insets | insets()
if (this.peer != null && this.peer instanceof ContainerPeer) {
ContainerPeer peer = (ContainerPeer)this.peer;
return (Insets)peer.insets().clone();
}
return new Insets(0, 0, 0, 0);
|
public void | invalidate()Invalidates the container. The container and all parents
above it are marked as needing to be laid out. This method can
be called often, so it needs to execute quickly.
LayoutManager layoutMgr = this.layoutMgr;
if (layoutMgr instanceof LayoutManager2) {
LayoutManager2 lm = (LayoutManager2) layoutMgr;
lm.invalidateLayout(this);
}
super.invalidate();
|
void | invalidateTree()Recursively descends the container tree and invalidates all
contained components.
synchronized (getTreeLock()) {
for (int i = 0; i < ncomponents; ++i) {
Component comp = component[i];
if (comp instanceof Container) {
((Container)comp).invalidateTree();
}
else {
if (comp.valid) {
comp.invalidate();
}
}
}
if (valid) {
invalidate();
}
}
|
public boolean | isAncestorOf(java.awt.Component c)Checks if the component is contained in the component hierarchy of
this container.
Container p;
if (c == null || ((p = c.getParent()) == null)) {
return false;
}
while (p != null) {
if (p == this) {
return true;
}
p = p.getParent();
}
return false;
|
public boolean | isFocusCycleRoot(java.awt.Container container)Returns whether the specified Container is the focus cycle root of this
Container's focus traversal cycle. Each focus traversal cycle has only
a single focus cycle root and each Container which is not a focus cycle
root belongs to only a single focus traversal cycle. Containers which
are focus cycle roots belong to two cycles: one rooted at the Container
itself, and one rooted at the Container's nearest focus-cycle-root
ancestor. This method will return true for both such
Containers in this case.
if (isFocusCycleRoot() && container == this) {
return true;
} else {
return super.isFocusCycleRoot(container);
}
|
public boolean | isFocusCycleRoot()Returns whether this Container is the root of a focus traversal cycle.
Once focus enters a traversal cycle, typically it cannot leave it via
focus traversal unless one of the up- or down-cycle keys is pressed.
Normal traversal is limited to this Container, and all of this
Container's descendants that are not descendants of inferior focus
cycle roots. Note that a FocusTraversalPolicy may bend these
restrictions, however. For example, ContainerOrderFocusTraversalPolicy
supports implicit down-cycle traversal.
return focusCycleRoot;
|
public final boolean | isFocusTraversalPolicyProvider()Returns whether this container provides focus traversal
policy. If this property is set to true then when
keyboard focus manager searches container hierarchy for focus
traversal policy and encounters this container before any other
container with this property as true or focus cycle roots then
its focus traversal policy will be used instead of focus cycle
root's policy.
return focusTraversalPolicyProvider;
|
public boolean | isFocusTraversalPolicySet()Returns whether the focus traversal policy has been explicitly set for
this Container. If this method returns false , this
Container will inherit its focus traversal policy from an ancestor.
return (focusTraversalPolicy != null);
|
boolean | isParentOf(java.awt.Component comp)Check if this component is the child of this container or its children.
Note: this function acquires treeLock
Note: this function traverses children tree only in one Window.
synchronized(getTreeLock()) {
while (comp != null && comp != this && !(comp instanceof Window)) {
comp = comp.getParent();
}
return (comp == this);
}
|
private static boolean | isRemoveNotifyNeeded(java.awt.Component comp, java.awt.Container oldContainer, java.awt.Container newContainer)Detects whether or not remove from current parent and adding to new parent requires call of
removeNotify on the component. Since removeNotify destroys native window this might (not)
be required. For example, if new container and old containers are the same we don't need to
destroy native window.
if (oldContainer == null) { // Component didn't have parent - no removeNotify
return false;
}
if (comp.peer == null) { // Component didn't have peer - no removeNotify
return false;
}
if (newContainer.peer == null) {
// Component has peer but new Container doesn't - call removeNotify
return true;
}
// If component is lightweight non-Container or lightweight Container with all but heavyweight
// children there is no need to call remove notify
if (comp.isLightweight()) {
if (comp instanceof Container) {
// If it has heavyweight children then removeNotify is required
return ((Container)comp).hasHeavyweightChildren();
} else {
// Just a lightweight
return false;
}
}
// All three components have peers, check for peer change
Container newNativeContainer = oldContainer.getHeavyweightContainer();
Container oldNativeContainer = newContainer.getHeavyweightContainer();
if (newNativeContainer != oldNativeContainer) {
// Native containers change - check whether or not current platform supports
// changing of widget hierarchy on native level without recreation.
return !comp.peer.isReparentSupported();
} else {
// if container didn't change we still might need to recreate component's window as
// changes to zorder should be reflected in native window stacking order and it might
// not be supported by the platform. This is important only for heavyweight child
return !comp.isLightweight() &&
!((ContainerPeer)(newNativeContainer.peer)).isRestackSupported();
}
|
boolean | isSameOrAncestorOf(java.awt.Component comp, boolean allowChildren)
return this == comp || (allowChildren && isParentOf(comp));
|
public void | layout()
LayoutManager layoutMgr = this.layoutMgr;
if (layoutMgr != null) {
layoutMgr.layoutContainer(this);
}
|
void | lightweightPaint(java.awt.Graphics g)Simulates the peer callbacks into java.awt for printing of
lightweight Containers.
super.lightweightPaint(g);
paintHeavyweightComponents(g);
|
void | lightweightPrint(java.awt.Graphics g)Simulates the peer callbacks into java.awt for printing of
lightweight Containers.
super.lightweightPrint(g);
printHeavyweightComponents(g);
|
public void | list(java.io.PrintStream out, int indent)Prints a listing of this container to the specified output
stream. The listing starts at the specified indentation.
The immediate children of the container are printed with
an indentation of indent+1 . The children
of those children are printed at indent+2
and so on.
super.list(out, indent);
int ncomponents = this.ncomponents;
Component component[] = this.component;
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp != null) {
comp.list(out, indent+1);
}
}
|
public void | list(java.io.PrintWriter out, int indent)Prints out a list, starting at the specified indentation,
to the specified print writer.
The immediate children of the container are printed with
an indentation of indent+1 . The children
of those children are printed at indent+2
and so on.
super.list(out, indent);
int ncomponents = this.ncomponents;
Component component[] = this.component;
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp != null) {
comp.list(out, indent+1);
}
}
|
public java.awt.Component | locate(int x, int y)
if (!contains(x, y)) {
return null;
}
synchronized (getTreeLock()) {
// Two passes: see comment in sun.awt.SunGraphicsCallback
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp != null &&
!(comp.peer instanceof LightweightPeer)) {
if (comp.contains(x - comp.x, y - comp.y)) {
return comp;
}
}
}
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i];
if (comp != null &&
comp.peer instanceof LightweightPeer) {
if (comp.contains(x - comp.x, y - comp.y)) {
return comp;
}
}
}
}
return this;
|
public java.awt.Dimension | minimumSize()
/* Avoid grabbing the lock if a reasonable cached size value
* is available.
*/
Dimension dim = minSize;
if (dim == null || !(isMinimumSizeSet() || isValid())) {
synchronized (getTreeLock()) {
minSize = (layoutMgr != null) ?
layoutMgr.minimumLayoutSize(this) :
super.minimumSize();
dim = minSize;
}
}
if (dim != null){
return new Dimension(dim);
}
else{
return dim;
}
|
boolean | nextFocusHelper()
if (isFocusCycleRoot()) {
Container root = findTraversalRoot();
Component comp = this;
Container anc;
while (root != null &&
(anc = root.getFocusCycleRootAncestor()) != null &&
!(root.isShowing() &&
root.isFocusable() &&
root.isEnabled()))
{
comp = root;
root = anc;
}
if (root != null) {
FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
Component toFocus = policy.getComponentAfter(root, comp);
if (toFocus == null) {
toFocus = policy.getDefaultComponent(root);
}
if (toFocus != null) {
return toFocus.requestFocus(false);
}
}
return false;
} else {
// I only have one root, so the general case will suffice
return super.nextFocusHelper();
}
|
int | numListening(long mask)
int superListening = super.numListening(mask);
if (mask == AWTEvent.HIERARCHY_EVENT_MASK) {
if (dbg.on) {
// Verify listeningChildren is correct
int sum = 0;
for (int i = 0; i < ncomponents; i++) {
sum += component[i].numListening(mask);
}
dbg.assertion(listeningChildren == sum);
}
return listeningChildren + superListening;
} else if (mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) {
if (dbg.on) {
// Verify listeningBoundsChildren is correct
int sum = 0;
for (int i = 0; i < ncomponents; i++) {
sum += component[i].numListening(mask);
}
dbg.assertion(listeningBoundsChildren == sum);
}
return listeningBoundsChildren + superListening;
} else {
if (dbg.on) {
dbg.assertion(false);
}
return superListening;
}
|
public void | paint(java.awt.Graphics g)Paints the container. This forwards the paint to any lightweight
components that are children of this container. If this method is
reimplemented, super.paint(g) should be called so that lightweight
components are properly rendered. If a child component is entirely
clipped by the current clipping setting in g, paint() will not be
forwarded to that child.
if (isShowing()) {
if (printing) {
synchronized (this) {
if (printing) {
if (printingThreads.contains(Thread.currentThread())) {
return;
}
}
}
}
// The container is showing on screen and
// this paint() is not called from print().
// Paint self and forward the paint to lightweight subcomponents.
// super.paint(); -- Don't bother, since it's a NOP.
GraphicsCallback.PaintCallback.getInstance().
runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS);
}
|
public void | paintComponents(java.awt.Graphics g)Paints each of the components in this container.
if (isShowing()) {
GraphicsCallback.PaintAllCallback.getInstance().
runComponents(component, g, GraphicsCallback.TWO_PASSES);
}
|
void | paintHeavyweightComponents(java.awt.Graphics g)Prints all the heavyweight subcomponents.
if (isShowing()) {
GraphicsCallback.PaintHeavyweightComponentsCallback.getInstance().
runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS |
GraphicsCallback.HEAVYWEIGHTS);
}
|
protected java.lang.String | paramString()Returns a string representing the state of this Container .
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 .
String str = super.paramString();
LayoutManager layoutMgr = this.layoutMgr;
if (layoutMgr != null) {
str += ",layout=" + layoutMgr.getClass().getName();
}
return str;
|
void | postProcessKeyEvent(java.awt.event.KeyEvent e)
Container parent = this.parent;
if (parent != null) {
parent.postProcessKeyEvent(e);
}
|
boolean | postsOldMouseEvents()
return true;
|
void | preProcessKeyEvent(java.awt.event.KeyEvent e)
Container parent = this.parent;
if (parent != null) {
parent.preProcessKeyEvent(e);
}
|
public java.awt.Dimension | preferredSize()
/* Avoid grabbing the lock if a reasonable cached size value
* is available.
*/
Dimension dim = prefSize;
if (dim == null || !(isPreferredSizeSet() || isValid())) {
synchronized (getTreeLock()) {
prefSize = (layoutMgr != null) ?
layoutMgr.preferredLayoutSize(this) :
super.preferredSize();
dim = prefSize;
}
}
if (dim != null){
return new Dimension(dim);
}
else{
return dim;
}
|
public void | print(java.awt.Graphics g)Prints the container. This forwards the print to any lightweight
components that are children of this container. If this method is
reimplemented, super.print(g) should be called so that lightweight
components are properly rendered. If a child component is entirely
clipped by the current clipping setting in g, print() will not be
forwarded to that child.
if (isShowing()) {
Thread t = Thread.currentThread();
try {
synchronized (this) {
if (printingThreads == null) {
printingThreads = new HashSet();
}
printingThreads.add(t);
printing = true;
}
super.print(g); // By default, Component.print() calls paint()
} finally {
synchronized (this) {
printingThreads.remove(t);
printing = !printingThreads.isEmpty();
}
}
GraphicsCallback.PrintCallback.getInstance().
runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS);
}
|
public void | printComponents(java.awt.Graphics g)Prints each of the components in this container.
if (isShowing()) {
GraphicsCallback.PrintAllCallback.getInstance().
runComponents(component, g, GraphicsCallback.TWO_PASSES);
}
|
void | printHeavyweightComponents(java.awt.Graphics g)Prints all the heavyweight subcomponents.
if (isShowing()) {
GraphicsCallback.PrintHeavyweightComponentsCallback.getInstance().
runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS |
GraphicsCallback.HEAVYWEIGHTS);
}
|
protected void | processContainerEvent(java.awt.event.ContainerEvent e)Processes container events occurring on this container by
dispatching them to any registered ContainerListener objects.
NOTE: This method will not be called unless container events
are enabled for this component; this happens when one of the
following occurs:
- A ContainerListener object is registered via
addContainerListener
- Container events are enabled via
enableEvents
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
ContainerListener listener = containerListener;
if (listener != null) {
switch(e.getID()) {
case ContainerEvent.COMPONENT_ADDED:
listener.componentAdded(e);
break;
case ContainerEvent.COMPONENT_REMOVED:
listener.componentRemoved(e);
break;
}
}
|
protected void | processEvent(java.awt.AWTEvent e)Processes events on this container. If the event is a
ContainerEvent , it invokes the
processContainerEvent method, else it invokes
its superclass's processEvent .
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
if (e instanceof ContainerEvent) {
processContainerEvent((ContainerEvent)e);
return;
}
super.processEvent(e);
|
void | proxyEnableEvents(long events)This is called by lightweight components that want the containing
windowed parent to enable some kind of events on their behalf.
This is needed for events that are normally only dispatched to
windows to be accepted so that they can be forwarded downward to
the lightweight component that has enabled them.
if (peer instanceof LightweightPeer) {
// this container is lightweight.... continue sending it
// upward.
if (parent != null) {
parent.proxyEnableEvents(events);
}
} else {
// This is a native container, so it needs to host
// one of it's children. If this function is called before
// a peer has been created we don't yet have a dispatcher
// because it has not yet been determined if this instance
// is lightweight.
if (dispatcher != null) {
dispatcher.enableEvents(events);
}
}
|
private void | readObject(java.io.ObjectInputStream s)Deserializes this Container from the specified
ObjectInputStream .
- Reads default serializable fields from the stream.
- Reads a list of serializable ContainerListener(s) as optional
data. If the list is null, no Listeners are installed.
- Reads this Container's FocusTraversalPolicy, which may be null,
as optional data.
ObjectInputStream.GetField f = s.readFields();
ncomponents = f.get("ncomponents", 0);
component = (Component[])f.get("component", new Component[0]);
layoutMgr = (LayoutManager)f.get("layoutMgr", null);
dispatcher = (LightweightDispatcher)f.get("dispatcher", null);
// Old stream. Doesn't contain maxSize among Component's fields.
if (maxSize == null) {
maxSize = (Dimension)f.get("maxSize", null);
}
focusCycleRoot = f.get("focusCycleRoot", false);
containerSerializedDataVersion = f.get("containerSerializedDataVersion", 1);
focusTraversalPolicyProvider = f.get("focusTraversalPolicyProvider", false);
Component component[] = this.component;
for(int i = 0; i < ncomponents; i++) {
component[i].parent = this;
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
component[i].numListening(AWTEvent.HIERARCHY_EVENT_MASK));
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
component[i].numListening(
AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
adjustDescendants(component[i].countHierarchyMembers());
}
Object keyOrNull;
while(null != (keyOrNull = s.readObject())) {
String key = ((String)keyOrNull).intern();
if (containerListenerK == key) {
addContainerListener((ContainerListener)(s.readObject()));
} else {
// skip value for unrecognized key
s.readObject();
}
}
try {
Object policy = s.readObject();
if (policy instanceof FocusTraversalPolicy) {
focusTraversalPolicy = (FocusTraversalPolicy)policy;
}
} catch (java.io.OptionalDataException e) {
// JDK 1.1/1.2/1.3 instances will not have this optional data.
// e.eof will be true to indicate that there is no more data
// available for this object. If e.eof is not true, throw the
// exception as it might have been caused by reasons unrelated to
// focusTraversalPolicy.
if (!e.eof) {
throw e;
}
}
|
public void | remove(int index)Removes the component, specified by index ,
from this container.
This method also notifies the layout manager to remove the
component from this container's layout via the
removeLayoutComponent method.
synchronized (getTreeLock()) {
if (index < 0 || index >= ncomponents) {
throw new ArrayIndexOutOfBoundsException(index);
}
Component comp = component[index];
if (peer != null) {
comp.removeNotify();
}
if (layoutMgr != null) {
layoutMgr.removeLayoutComponent(comp);
}
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
-comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
-comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
adjustDescendants(-(comp.countHierarchyMembers()));
comp.parent = null;
System.arraycopy(component, index + 1,
component, index,
ncomponents - index - 1);
component[--ncomponents] = null;
if (valid) {
invalidate();
}
if (containerListener != null ||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
ContainerEvent e = new ContainerEvent(this,
ContainerEvent.COMPONENT_REMOVED,
comp);
dispatchEvent(e);
}
comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
this, HierarchyEvent.PARENT_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
if (peer != null && layoutMgr == null && isVisible()) {
updateCursorImmediately();
}
}
|
public void | remove(java.awt.Component comp)Removes the specified component from this container.
This method also notifies the layout manager to remove the
component from this container's layout via the
removeLayoutComponent method.
synchronized (getTreeLock()) {
if (comp.parent == this) {
/* Search backwards, expect that more recent additions
* are more likely to be removed.
*/
Component component[] = this.component;
for (int i = ncomponents; --i >= 0; ) {
if (component[i] == comp) {
remove(i);
}
}
}
}
|
public void | removeAll()Removes all the components from this container.
This method also notifies the layout manager to remove the
components from this container's layout via the
removeLayoutComponent method.
synchronized (getTreeLock()) {
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
-listeningChildren);
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
-listeningBoundsChildren);
adjustDescendants(-descendantsCount);
while (ncomponents > 0) {
Component comp = component[--ncomponents];
component[ncomponents] = null;
if (peer != null) {
comp.removeNotify();
}
if (layoutMgr != null) {
layoutMgr.removeLayoutComponent(comp);
}
comp.parent = null;
if (containerListener != null ||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
ContainerEvent e = new ContainerEvent(this,
ContainerEvent.COMPONENT_REMOVED,
comp);
dispatchEvent(e);
}
comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
comp, this,
HierarchyEvent.PARENT_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
}
if (peer != null && layoutMgr == null && isVisible()) {
updateCursorImmediately();
}
if (valid) {
invalidate();
}
}
|
public synchronized void | removeContainerListener(java.awt.event.ContainerListener l)Removes the specified container listener so it no longer receives
container events from this container.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
containerListener = AWTEventMulticaster.remove(containerListener, l);
|
private void | removeDelicately(java.awt.Component comp, java.awt.Container newParent, int newIndex)Removes component comp from this container without making unneccessary changes
and generating unneccessary events. This function intended to perform optimized
remove, for example, if newParent and current parent are the same it just changes
index without calling removeNotify.
Note: Should be called while holding treeLock
checkTreeLock();
int index = getComponentZOrder(comp);
if (isRemoveNotifyNeeded(comp, this, newParent)) {
comp.removeNotify();
}
if (newParent != this) {
if (layoutMgr != null) {
layoutMgr.removeLayoutComponent(comp);
}
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
-comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
-comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
adjustDescendants(-(comp.countHierarchyMembers()));
comp.parent = null;
System.arraycopy(component, index + 1,
component, index,
ncomponents - index - 1);
component[--ncomponents] = null;
if (valid) {
invalidate();
}
} else {
if (newIndex > index) { // 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
if (newIndex-index > 0) {
System.arraycopy(component, index+1, component, index, newIndex-index);
}
} else { // 4->2: 012345 -> 014235
if (index-newIndex > 0) {
System.arraycopy(component, newIndex, component, newIndex+1, index-newIndex);
}
}
component[newIndex] = comp;
}
if (comp.parent == null) { // was actually removed
if (containerListener != null ||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
ContainerEvent e = new ContainerEvent(this,
ContainerEvent.COMPONENT_REMOVED,
comp);
dispatchEvent(e);
}
comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
this, HierarchyEvent.PARENT_CHANGED,
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
if (peer != null && layoutMgr == null && isVisible()) {
updateCursorImmediately();
}
}
|
public void | removeNotify()Makes this Container undisplayable by removing its connection
to its native screen resource. Making a container undisplayable
will cause all of its children to be made undisplayable.
This method is called by the toolkit internally and should
not be called directly by programs.
synchronized (getTreeLock()) {
int ncomponents = this.ncomponents;
Component component[] = this.component;
for (int i = ncomponents-1 ; i >= 0 ; i--) {
if( component[i] != null )
component[i].removeNotify();
}
if ( dispatcher != null ) {
dispatcher.dispose();
dispatcher = null;
}
super.removeNotify();
}
|
private void | reparentChild(java.awt.Component comp)Reparents child component peer to this container peer.
Container must be heavyweight.
checkTreeLock();
if (comp == null) {
return;
}
if (comp.isLightweight()) {
// If component is lightweight container we need to reparent all its explicit heavyweight children
if (comp instanceof Container) {
// Traverse component's tree till depth-first until encountering heavyweight component
reparentTraverse((ContainerPeer)getPeer(), (Container)comp);
}
} else {
comp.getPeer().reparent((ContainerPeer)getPeer());
}
|
private void | reparentTraverse(java.awt.peer.ContainerPeer parentPeer, java.awt.Container child)Traverses the tree of components and reparents children heavyweight component
to new heavyweight parent.
checkTreeLock();
for (int i = 0; i < child.getComponentCount(); i++) {
Component comp = child.getComponent(i);
if (comp.isLightweight()) {
// If components is lightweight check if it is container
// If it is container it might contain heavyweight children we need to reparent
if (comp instanceof Container) {
reparentTraverse(parentPeer, (Container)comp);
}
} else {
// Q: Need to update NativeInLightFixer?
comp.getPeer().reparent(parentPeer);
}
}
|
public final void | setComponentZOrder(java.awt.Component comp, int index)Moves the specified component to the specified z-order index in
the container. The z-order determines the order that components
are painted; the component with the highest z-order paints first
and the component with the lowest z-order paints last.
Where components overlap, the component with the lower
z-order paints over the component with the higher z-order.
If the component is a child of some other container, it is
removed from that container before being added to this container.
The important difference between this method and
java.awt.Container.add(Component, int) is that this method
doesn't call removeNotify on the component while
removing it from its previous container unless necessary and when
allowed by the underlying native windowing system. This way, if the
component has the keyboard focus, it maintains the focus when
moved to the new position.
This property is guaranteed to apply only to lightweight
non-Container components.
Note: Not all platforms support changing the z-order of
heavyweight components from one container into another without
the call to removeNotify . There is no way to detect
whether a platform supports this, so developers shouldn't make
any assumptions.
synchronized (getTreeLock()) {
// Store parent because remove will clear it
Container curParent = comp.parent;
if (curParent == this && index == getComponentZOrder(comp)) {
return;
}
checkAdding(comp, index);
if (curParent != null) {
curParent.removeDelicately(comp, this, index);
}
addDelicately(comp, curParent, index);
}
|
public void | setFocusCycleRoot(boolean focusCycleRoot)Sets whether this Container is the root of a focus traversal cycle. Once
focus enters a traversal cycle, typically it cannot leave it via focus
traversal unless one of the up- or down-cycle keys is pressed. Normal
traversal is limited to this Container, and all of this Container's
descendants that are not descendants of inferior focus cycle roots. Note
that a FocusTraversalPolicy may bend these restrictions, however. For
example, ContainerOrderFocusTraversalPolicy supports implicit down-cycle
traversal.
The alternative way to specify the traversal order of this Container's
children is to make this Container a
focus traversal policy provider.
boolean oldFocusCycleRoot;
synchronized (this) {
oldFocusCycleRoot = this.focusCycleRoot;
this.focusCycleRoot = focusCycleRoot;
}
firePropertyChange("focusCycleRoot", oldFocusCycleRoot,
focusCycleRoot);
|
public void | setFocusTraversalKeys(int id, java.util.Set keystrokes)Sets the focus traversal keys for a given traversal operation for this
Container.
The default values for a Container's focus traversal keys are
implementation-dependent. Sun recommends that all implementations for a
particular native platform use the same default values. The
recommendations for Windows and Unix are listed below. These
recommendations are used in the Sun AWT implementations.
Identifier |
Meaning |
Default |
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS |
Normal forward keyboard traversal |
TAB on KEY_PRESSED, CTRL-TAB on KEY_PRESSED |
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS |
Normal reverse keyboard traversal |
SHIFT-TAB on KEY_PRESSED, CTRL-SHIFT-TAB on KEY_PRESSED |
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS |
Go up one focus traversal cycle |
none |
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS |
| Go down one focus traversal cycle |
none |
To disable a traversal key, use an empty Set; Collections.EMPTY_SET is
recommended.
Using the AWTKeyStroke API, client code can specify on which of two
specific KeyEvents, KEY_PRESSED or KEY_RELEASED, the focus traversal
operation will occur. Regardless of which KeyEvent is specified,
however, all KeyEvents related to the focus traversal key, including the
associated KEY_TYPED event, will be consumed, and will not be dispatched
to any Container. It is a runtime error to specify a KEY_TYPED event as
mapping to a focus traversal operation, or to map the same event to
multiple default focus traversal operations.
If a value of null is specified for the Set, this Container inherits the
Set from its parent. If all ancestors of this Container have null
specified for the Set, then the current KeyboardFocusManager's default
Set is used.
if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) {
throw new IllegalArgumentException("invalid focus traversal key identifier");
}
// Don't call super.setFocusTraversalKey. The Component parameter check
// does not allow DOWN_CYCLE_TRAVERSAL_KEYS, but we do.
setFocusTraversalKeys_NoIDCheck(id, keystrokes);
|
public void | setFocusTraversalPolicy(java.awt.FocusTraversalPolicy policy)Sets the focus traversal policy that will manage keyboard traversal of
this Container's children, if this Container is a focus cycle root. If
the argument is null, this Container inherits its policy from its focus-
cycle-root ancestor. If the argument is non-null, this policy will be
inherited by all focus-cycle-root children that have no keyboard-
traversal policy of their own (as will, recursively, their focus-cycle-
root children).
If this Container is not a focus cycle root, the policy will be
remembered, but will not be used or inherited by this or any other
Containers until this Container is made a focus cycle root.
FocusTraversalPolicy oldPolicy;
synchronized (this) {
oldPolicy = this.focusTraversalPolicy;
this.focusTraversalPolicy = policy;
}
firePropertyChange("focusTraversalPolicy", oldPolicy, policy);
|
public final void | setFocusTraversalPolicyProvider(boolean provider)Sets whether this container will be used to provide focus
traversal policy. Container with this property as
true will be used to acquire focus traversal policy
instead of closest focus cycle root ancestor.
boolean oldProvider;
synchronized(this) {
oldProvider = focusTraversalPolicyProvider;
focusTraversalPolicyProvider = provider;
}
firePropertyChange("focusTraversalPolicyProvider", oldProvider, provider);
|
public void | setFont(java.awt.Font f)Sets the font of this container.
boolean shouldinvalidate = false;
Font oldfont = getFont();
super.setFont(f);
Font newfont = getFont();
if (newfont != oldfont && (oldfont == null ||
!oldfont.equals(newfont))) {
invalidateTree();
}
|
public void | setLayout(java.awt.LayoutManager mgr)Sets the layout manager for this container.
layoutMgr = mgr;
if (valid) {
invalidate();
}
|
private void | startLWModal()
// Store the app context on which this component is being shown.
// Event dispatch thread of this app context will be sleeping until
// we wake it by any event from hideAndDisposeHandler().
modalAppContext = AppContext.getAppContext();
// keep the KeyEvents from being dispatched
// until the focus has been transfered
long time = Toolkit.getEventQueue().getMostRecentEventTime();
Component predictedFocusOwner = (this instanceof javax.swing.JInternalFrame) ? ((javax.swing.JInternalFrame)(this)).getMostRecentFocusOwner() : null;
if (predictedFocusOwner != null) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
enqueueKeyEvents(time, predictedFocusOwner);
}
// We have two mechanisms for blocking: 1. If we're on the
// EventDispatchThread, start a new event pump. 2. If we're
// on any other thread, call wait() on the treelock.
final Container nativeContainer;
synchronized (getTreeLock()) {
nativeContainer = getHeavyweightContainer();
if (nativeContainer.modalComp != null) {
this.modalComp = nativeContainer.modalComp;
nativeContainer.modalComp = this;
return;
}
else {
nativeContainer.modalComp = this;
}
}
Runnable pumpEventsForHierarchy = new Runnable() {
public void run() {
EventDispatchThread dispatchThread =
(EventDispatchThread)Thread.currentThread();
dispatchThread.pumpEventsForHierarchy(
new Conditional() {
public boolean evaluate() {
return ((windowClosingException == null) && (nativeContainer.modalComp != null)) ;
}
}, Container.this);
}
};
if (EventQueue.isDispatchThread()) {
SequencedEvent currentSequencedEvent =
KeyboardFocusManager.getCurrentKeyboardFocusManager().
getCurrentSequencedEvent();
if (currentSequencedEvent != null) {
currentSequencedEvent.dispose();
}
pumpEventsForHierarchy.run();
} else {
synchronized (getTreeLock()) {
Toolkit.getEventQueue().
postEvent(new PeerEvent(this,
pumpEventsForHierarchy,
PeerEvent.PRIORITY_EVENT));
while (windowClosingException == null) {
try {
getTreeLock().wait();
} catch (InterruptedException e) {
break;
}
}
}
}
if (windowClosingException != null) {
windowClosingException.fillInStackTrace();
throw windowClosingException;
}
if (predictedFocusOwner != null) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
dequeueKeyEvents(time, predictedFocusOwner);
}
|
private void | stopLWModal()
synchronized (getTreeLock()) {
if (modalAppContext != null) {
Container nativeContainer = getHeavyweightContainer();
if(nativeContainer != null) {
if (this.modalComp != null) {
nativeContainer.modalComp = this.modalComp;
this.modalComp = null;
return;
}
else {
nativeContainer.modalComp = null;
}
}
// Wake up event dispatch thread on which the dialog was
// initially shown
SunToolkit.postEvent(modalAppContext,
new PeerEvent(this,
new WakingRunnable(),
PeerEvent.PRIORITY_EVENT));
}
EventQueue.invokeLater(new WakingRunnable());
getTreeLock().notifyAll();
}
|
public void | transferFocusBackward()
if (isFocusCycleRoot()) {
Container root = findTraversalRoot();
Component comp = this;
while (root != null &&
!(root.isShowing() &&
root.isFocusable() &&
root.isEnabled()))
{
comp = root;
root = comp.getFocusCycleRootAncestor();
}
if (root != null) {
FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
Component toFocus = policy.getComponentBefore(root, comp);
if (toFocus == null) {
toFocus = policy.getDefaultComponent(root);
}
if (toFocus != null) {
toFocus.requestFocus();
}
}
} else {
// I only have one root, so the general case will suffice
super.transferFocusBackward();
}
|
public void | transferFocusDownCycle()Transfers the focus down one focus traversal cycle. If this Container is
a focus cycle root, then the focus owner is set to this Container's
default Component to focus, and the current focus cycle root is set to
this Container. If this Container is not a focus cycle root, then no
focus traversal operation occurs.
if (isFocusCycleRoot()) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRoot(this);
Component toFocus = getFocusTraversalPolicy().
getDefaultComponent(this);
if (toFocus != null) {
toFocus.requestFocus();
}
}
|
public void | update(java.awt.Graphics g)Updates the container. This forwards the update to any lightweight
components that are children of this container. If this method is
reimplemented, super.update(g) should be called so that lightweight
components are properly rendered. If a child component is entirely
clipped by the current clipping setting in g, update() will not be
forwarded to that child.
if (isShowing()) {
if (! (peer instanceof LightweightPeer)) {
g.clearRect(0, 0, width, height);
}
paint(g);
}
|
public void | validate()Validates this container and all of its subcomponents.
The validate method is used to cause a container
to lay out its subcomponents again. It should be invoked when
this container's subcomponents are modified (added to or
removed from the container, or layout-related information
changed) after the container has been displayed.
/* Avoid grabbing lock unless really necessary. */
if (!valid) {
boolean updateCur = false;
synchronized (getTreeLock()) {
if (!valid && peer != null) {
ContainerPeer p = null;
if (peer instanceof ContainerPeer) {
p = (ContainerPeer) peer;
}
if (p != null) {
p.beginValidate();
}
validateTree();
valid = true;
if (p != null) {
p.endValidate();
updateCur = isVisible();
}
}
}
if (updateCur) {
updateCursorImmediately();
}
}
|
protected void | validateTree()Recursively descends the container tree and recomputes the
layout for any subtrees marked as needing it (those marked as
invalid). Synchronization should be provided by the method
that calls this one: validate .
if (!valid) {
if (peer instanceof ContainerPeer) {
((ContainerPeer)peer).beginLayout();
}
doLayout();
Component component[] = this.component;
for (int i = 0 ; i < ncomponents ; ++i) {
Component comp = component[i];
if ( (comp instanceof Container)
&& !(comp instanceof Window)
&& !comp.valid) {
((Container)comp).validateTree();
} else {
comp.validate();
}
}
if (peer instanceof ContainerPeer) {
((ContainerPeer)peer).endLayout();
}
}
valid = true;
|
private void | writeObject(java.io.ObjectOutputStream s)Serializes this Container to the specified
ObjectOutputStream .
- Writes default serializable fields to the stream.
- Writes a list of serializable ContainerListener(s) as optional
data. The non-serializable ContainerListner(s) are detected and
no attempt is made to serialize them.
- Write this Container's FocusTraversalPolicy if and only if it
is Serializable; otherwise,
null is written.
ObjectOutputStream.PutField f = s.putFields();
f.put("ncomponents", ncomponents);
f.put("component", component);
f.put("layoutMgr", layoutMgr);
f.put("dispatcher", dispatcher);
f.put("maxSize", maxSize);
f.put("focusCycleRoot", focusCycleRoot);
f.put("containerSerializedDataVersion", containerSerializedDataVersion);
f.put("focusTraversalPolicyProvider", focusTraversalPolicyProvider);
s.writeFields();
AWTEventMulticaster.save(s, containerListenerK, containerListener);
s.writeObject(null);
if (focusTraversalPolicy instanceof java.io.Serializable) {
s.writeObject(focusTraversalPolicy);
} else {
s.writeObject(null);
}
|