Source Code Cross Referenced for Container.java in  » Apache-Harmony-Java-SE » java-package » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
0003:         *  contributor license agreements.  See the NOTICE file distributed with
0004:         *  this work for additional information regarding copyright ownership.
0005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
0006:         *  (the "License"); you may not use this file except in compliance with
0007:         *  the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         *  Unless required by applicable law or agreed to in writing, software
0012:         *  distributed under the License is distributed on an "AS IS" BASIS,
0013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         *  See the License for the specific language governing permissions and
0015:         *  limitations under the License.
0016:         */
0017:
0018:        package java.awt;
0019:
0020:        import java.awt.event.ContainerEvent;
0021:        import java.awt.event.ContainerListener;
0022:        import java.awt.event.HierarchyEvent;
0023:        import java.beans.PropertyChangeListener;
0024:        import java.io.PrintStream;
0025:        import java.io.PrintWriter;
0026:        import java.util.EventListener;
0027:        import java.util.Iterator;
0028:        import java.util.Set;
0029:
0030:        import java.util.Vector;
0031:
0032:        import javax.accessibility.Accessible;
0033:        import javax.accessibility.AccessibleComponent;
0034:        import javax.accessibility.AccessibleContext;
0035:
0036:        import org.apache.harmony.awt.internal.nls.Messages;
0037:
0038:        import org.apache.harmony.awt.gl.MultiRectArea;
0039:
0040:        public class Container extends Component {
0041:            private static final long serialVersionUID = 4613797578919906343L;
0042:
0043:            private final Vector<Component> children = new Vector<Component>();
0044:
0045:            private final AWTListenerList<ContainerListener> containerListeners = new AWTListenerList<ContainerListener>(
0046:                    this );
0047:
0048:            private FocusTraversalPolicy focusTraversalPolicy;
0049:
0050:            private LayoutManager layout;
0051:
0052:            private Dimension minimumLayoutSize;
0053:
0054:            private Dimension preferredLayoutSize;
0055:
0056:            Object layoutData;
0057:
0058:            boolean focusCycleRoot;
0059:
0060:            private boolean focusTraversalPolicyProvider;
0061:
0062:            boolean isRemoved; // set to true/false on removeNotify() enter/exit
0063:
0064:            protected class AccessibleAWTContainer extends
0065:                    AccessibleAWTComponent {
0066:                private static final long serialVersionUID = 5081320404842566097L;
0067:
0068:                protected class AccessibleContainerHandler implements 
0069:                        ContainerListener {
0070:                    protected AccessibleContainerHandler() {
0071:
0072:                    }
0073:
0074:                    public void componentAdded(ContainerEvent e) {
0075:                        if (listenersCount <= 0) {
0076:                            return;
0077:                        }
0078:                        firePropertyChange(
0079:                                AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
0080:                                null, e.getChild().getAccessibleContext());
0081:
0082:                    }
0083:
0084:                    public void componentRemoved(ContainerEvent e) {
0085:                        if (listenersCount <= 0) {
0086:                            return;
0087:                        }
0088:                        firePropertyChange(
0089:                                AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, e
0090:                                        .getChild().getAccessibleContext(),
0091:                                null);
0092:
0093:                    }
0094:
0095:                }
0096:
0097:                protected ContainerListener accessibleContainerHandler;
0098:
0099:                protected AccessibleAWTContainer() {
0100:                }
0101:
0102:                @Override
0103:                public void addPropertyChangeListener(
0104:                        PropertyChangeListener listener) {
0105:                    super .addPropertyChangeListener(listener);
0106:                    if (accessibleContainerHandler != null) {
0107:                        return;
0108:                    }
0109:                    accessibleContainerHandler = new AccessibleContainerHandler();
0110:                    Container.this 
0111:                            .addContainerListener(accessibleContainerHandler);
0112:                }
0113:
0114:                @Override
0115:                public Accessible getAccessibleAt(Point p) {
0116:                    toolkit.lockAWT();
0117:                    try {
0118:                        if (!(Container.this  instanceof  Accessible)
0119:                                || (getAccessibleContext() == null)) {
0120:                            return super .getAccessibleAt(p);
0121:                        }
0122:                        int count = getAccessibleChildrenCount();
0123:                        for (int i = 0; i < count; i++) {
0124:                            Accessible aChild = getAccessibleChild(i);
0125:                            AccessibleContext ac = aChild
0126:                                    .getAccessibleContext();
0127:                            if (ac != null) {
0128:                                AccessibleComponent aComp = ac
0129:                                        .getAccessibleComponent();
0130:                                Point pos = new Point(p);
0131:                                Point loc = aComp.getLocation();
0132:                                pos.translate(-loc.x, -loc.y);
0133:                                if (aComp.isShowing() && aComp.contains(pos)) {
0134:                                    return aChild;
0135:                                }
0136:                            }
0137:
0138:                        }
0139:                        return (Accessible) Container.this ;
0140:                    } finally {
0141:                        toolkit.unlockAWT();
0142:                    }
0143:                }
0144:
0145:                @Override
0146:                public Accessible getAccessibleChild(int index) {
0147:                    toolkit.lockAWT();
0148:                    try {
0149:                        int count = 0;
0150:                        for (int i = 0; i < children.size(); i++) {
0151:                            if (children.get(i) instanceof  Accessible) {
0152:                                if (count == index) {
0153:                                    return (Accessible) children.get(i);
0154:                                }
0155:                                ++count;
0156:                            }
0157:                        }
0158:                        return null;
0159:                    } finally {
0160:                        toolkit.unlockAWT();
0161:                    }
0162:                }
0163:
0164:                @Override
0165:                public int getAccessibleChildrenCount() {
0166:                    toolkit.lockAWT();
0167:                    try {
0168:                        int count = 0;
0169:                        for (int i = 0; i < children.size(); i++) {
0170:                            if (children.get(i) instanceof  Accessible) {
0171:                                ++count;
0172:                            }
0173:                        }
0174:                        return count;
0175:                    } finally {
0176:                        toolkit.unlockAWT();
0177:                    }
0178:                }
0179:            }
0180:
0181:            public Container() {
0182:                toolkit.lockAWT();
0183:                try {
0184:                } finally {
0185:                    toolkit.unlockAWT();
0186:                }
0187:            }
0188:
0189:            int getComponentIndex(Component comp) {
0190:                return children.indexOf(comp);
0191:            }
0192:
0193:            public final int getComponentZOrder(Component comp) {
0194:                toolkit.lockAWT();
0195:                try {
0196:                    return children.indexOf(comp);
0197:                } finally {
0198:                    toolkit.unlockAWT();
0199:                }
0200:            }
0201:
0202:            /*
0203:             * places component at the index pos. of the stacking order (e. g. when it
0204:             * gains focus)
0205:             */
0206:            public final void setComponentZOrder(Component comp, int index) {
0207:                toolkit.lockAWT();
0208:                try {
0209:                    int oldIndex = getComponentZOrder(comp);
0210:
0211:                    if (children.remove(comp)) {
0212:                        children.add(index, comp);
0213:                    }
0214:                    comp.behaviour.setZOrder(index, oldIndex);
0215:                } finally {
0216:                    toolkit.unlockAWT();
0217:                }
0218:            }
0219:
0220:            public Component add(Component comp) {
0221:                toolkit.lockAWT();
0222:                try {
0223:                    // add component to the bottom of the stacking order
0224:                    addImpl(comp, null, -1);
0225:
0226:                    return comp;
0227:                } finally {
0228:                    toolkit.unlockAWT();
0229:                }
0230:            }
0231:
0232:            public Component add(Component comp, int index) {
0233:                toolkit.lockAWT();
0234:                try {
0235:                    addImpl(comp, null, index);
0236:
0237:                    return comp;
0238:                } finally {
0239:                    toolkit.unlockAWT();
0240:                }
0241:            }
0242:
0243:            public void add(Component comp, Object constraints, int index) {
0244:                toolkit.lockAWT();
0245:                try {
0246:                    addImpl(comp, constraints, index);
0247:                } finally {
0248:                    toolkit.unlockAWT();
0249:                }
0250:            }
0251:
0252:            public void add(Component comp, Object constraints) {
0253:                toolkit.lockAWT();
0254:                try {
0255:                    addImpl(comp, constraints, -1);
0256:                } finally {
0257:                    toolkit.unlockAWT();
0258:                }
0259:            }
0260:
0261:            public Component add(String name, Component comp) {
0262:                toolkit.lockAWT();
0263:                try {
0264:                    addImpl(comp, name, -1);
0265:                    return comp;
0266:                } finally {
0267:                    toolkit.unlockAWT();
0268:                }
0269:            }
0270:
0271:            public void remove(int index) {
0272:                toolkit.lockAWT();
0273:                try {
0274:                    Component comp = children.get(index);
0275:
0276:                    if (layout != null) {
0277:                        layout.removeLayoutComponent(comp);
0278:                    }
0279:                    removeFromContainer(index);
0280:                    // container events are synchronous
0281:                    dispatchEvent(new ContainerEvent(this ,
0282:                            ContainerEvent.COMPONENT_REMOVED, comp));
0283:                } finally {
0284:                    toolkit.unlockAWT();
0285:                }
0286:            }
0287:
0288:            public void remove(Component comp) {
0289:                toolkit.lockAWT();
0290:                try {
0291:                    if (comp == null) {
0292:                        throw new NullPointerException();
0293:                    }
0294:
0295:                    try {
0296:                        remove(children.indexOf(comp));
0297:                    } catch (ArrayIndexOutOfBoundsException e) {
0298:                        // just silently ignore exception if comp is not found
0299:                    }
0300:                } finally {
0301:                    toolkit.unlockAWT();
0302:                }
0303:            }
0304:
0305:            @Override
0306:            public void list(PrintWriter out, int indent) {
0307:                toolkit.lockAWT();
0308:                try {
0309:                    super .list(out, indent);
0310:                    for (int i = 0; i < children.size(); i++) {
0311:                        children.get(i).list(out, 2 * indent);
0312:                    }
0313:                } finally {
0314:                    toolkit.unlockAWT();
0315:                }
0316:            }
0317:
0318:            @Override
0319:            public void list(PrintStream out, int indent) {
0320:                toolkit.lockAWT();
0321:                try {
0322:                    super .list(out, indent);
0323:                    for (int i = 0; i < children.size(); i++) {
0324:                        children.get(i).list(out, 2 * indent);
0325:                    }
0326:                } finally {
0327:                    toolkit.unlockAWT();
0328:                }
0329:            }
0330:
0331:            @Override
0332:            public void print(Graphics g) {
0333:                toolkit.lockAWT();
0334:                try {
0335:                    paint(g);
0336:                } finally {
0337:                    toolkit.unlockAWT();
0338:                }
0339:            }
0340:
0341:            public void removeAll() {
0342:                toolkit.lockAWT();
0343:                try {
0344:                    for (int i = children.size() - 1; i >= 0; i--) {
0345:                        remove(i);
0346:                    }
0347:                } finally {
0348:                    toolkit.unlockAWT();
0349:                }
0350:            }
0351:
0352:            @Override
0353:            public void update(Graphics g) {
0354:                toolkit.lockAWT();
0355:                try {
0356:                    super .update(g); // calls paint() by default
0357:                } finally {
0358:                    toolkit.unlockAWT();
0359:                }
0360:            }
0361:
0362:            private int addToContainer(Component comp, int index) {
0363:                int retIndex = index;
0364:                int size = children.size();
0365:
0366:                comp.prepare4HierarchyChange();
0367:
0368:                retIndex = ((index >= 0) && (index < size)) ? index : size;
0369:                children.add(retIndex, comp);
0370:                comp.setParent(this );
0371:                if (isDisplayable()) {
0372:                    comp.mapToDisplay(true);
0373:                }
0374:                invalidate();
0375:
0376:                comp.finishHierarchyChange(comp, this ,
0377:                        HierarchyEvent.PARENT_CHANGED);
0378:
0379:                return retIndex;
0380:            }
0381:
0382:            private void removeFromContainer(int index) {
0383:                Component comp = children.get(index);
0384:
0385:                comp.prepare4HierarchyChange();
0386:
0387:                if (isDisplayable()) {
0388:                    comp.mapToDisplay(false);
0389:                }
0390:
0391:                children.remove(index);
0392:
0393:                comp.setParent(null);
0394:                invalidate();
0395:
0396:                comp.finishHierarchyChange(comp, this ,
0397:                        HierarchyEvent.PARENT_CHANGED);
0398:            }
0399:
0400:            private void addToLayout(Component comp, Object constraints) {
0401:                if (layout != null) {
0402:                    if (LayoutManager2.class.isInstance(layout)) {
0403:                        ((LayoutManager2) layout).addLayoutComponent(comp,
0404:                                constraints);
0405:                    } else {
0406:                        layout.addLayoutComponent((constraints == null) ? null
0407:                                : constraints.toString(), comp);
0408:                    }
0409:                }
0410:            }
0411:
0412:            protected void addImpl(Component comp, Object constraints, int index)
0413:                    throws IllegalArgumentException {
0414:                toolkit.lockAWT();
0415:                try {
0416:                    if ((index < -1) || (index > children.size())) {
0417:                        // awt.12A=illegal component position
0418:                        throw new IllegalArgumentException(Messages
0419:                                .getString("awt.12A")); //$NON-NLS-1$
0420:                    }
0421:                    if ((comp instanceof  Container)) {
0422:                        if (comp == this ) {
0423:                            // awt.12B=adding container to itself
0424:                            throw new IllegalArgumentException(Messages
0425:                                    .getString("awt.12B")); //$NON-NLS-1$
0426:                        } else if (((Container) comp).isAncestorOf(this )) {
0427:                            // awt.12C=adding container's parent to itself
0428:                            throw new IllegalArgumentException(Messages
0429:                                    .getString("awt.12C")); //$NON-NLS-1$
0430:                        } else if (comp instanceof  Window) {
0431:                            // awt.12D=adding a window to a container
0432:                            throw new IllegalArgumentException(Messages
0433:                                    .getString("awt.12D")); //$NON-NLS-1$
0434:                        }
0435:                    }
0436:
0437:                    if (comp.getParent() != null) {
0438:                        comp.getParent().remove(comp);
0439:                    }
0440:                    int trueIndex = addToContainer(comp, index);
0441:                    try {
0442:                        addToLayout(comp, constraints);
0443:                    } catch (IllegalArgumentException e) {
0444:                        removeFromContainer(trueIndex);
0445:                        throw e;
0446:                    }
0447:                    comp.behaviour.setZOrder(index, trueIndex);
0448:
0449:                    // calculated preferred/minimum sizes should be reset
0450:                    // because they depend on inherited font
0451:                    comp.resetDefaultSize();
0452:                    // container events are synchronous
0453:                    dispatchEvent(new ContainerEvent(this ,
0454:                            ContainerEvent.COMPONENT_ADDED, comp));
0455:                } finally {
0456:                    toolkit.unlockAWT();
0457:                }
0458:            }
0459:
0460:            @Override
0461:            public void addNotify() {
0462:                toolkit.lockAWT();
0463:                try {
0464:                    super .addNotify();
0465:                    for (int i = 0; i < children.size(); i++) {
0466:                        children.get(i).addNotify();
0467:                    }
0468:                } finally {
0469:                    toolkit.unlockAWT();
0470:                }
0471:            }
0472:
0473:            @Override
0474:            public void addPropertyChangeListener(
0475:                    PropertyChangeListener listener) {
0476:                toolkit.lockAWT();
0477:                try {
0478:                    super .addPropertyChangeListener(listener);
0479:                } finally {
0480:                    toolkit.unlockAWT();
0481:                }
0482:            }
0483:
0484:            @Override
0485:            public void addPropertyChangeListener(String propertyName,
0486:                    PropertyChangeListener listener) {
0487:                toolkit.lockAWT();
0488:                try {
0489:                    super .addPropertyChangeListener(propertyName, listener);
0490:                } finally {
0491:                    toolkit.unlockAWT();
0492:                }
0493:            }
0494:
0495:            @Override
0496:            public void applyComponentOrientation(ComponentOrientation o) {
0497:                toolkit.lockAWT();
0498:                try {
0499:                    super .applyComponentOrientation(o);
0500:                    for (int i = 0; i < children.size(); i++) {
0501:                        children.get(i).applyComponentOrientation(o);
0502:                    }
0503:                } finally {
0504:                    toolkit.unlockAWT();
0505:                }
0506:            }
0507:
0508:            @Override
0509:            public boolean areFocusTraversalKeysSet(int id) {
0510:                toolkit.lockAWT();
0511:                try {
0512:                    return super .areFocusTraversalKeysSet(id);
0513:                } finally {
0514:                    toolkit.unlockAWT();
0515:                }
0516:            }
0517:
0518:            /**
0519:             * @deprecated
0520:             */
0521:            @Deprecated
0522:            public int countComponents() {
0523:                toolkit.lockAWT();
0524:                try {
0525:                    return children.size();
0526:                } finally {
0527:                    toolkit.unlockAWT();
0528:                }
0529:            }
0530:
0531:            /**
0532:             * @deprecated
0533:             */
0534:            @SuppressWarnings("deprecation")
0535:            @Deprecated
0536:            @Override
0537:            public void deliverEvent(Event evt) {
0538:
0539:                Component comp = getComponentAt(evt.x, evt.y);
0540:                if (comp != null && comp != this ) {
0541:                    evt.translate(-comp.getX(), -comp.getY());
0542:                    comp.deliverEvent(evt);
0543:                } else {
0544:                    super .deliverEvent(evt);
0545:                }
0546:
0547:            }
0548:
0549:            @Override
0550:            public void doLayout() {
0551:                toolkit.lockAWT();
0552:                try {
0553:                    layout();
0554:                } finally {
0555:                    toolkit.unlockAWT();
0556:                }
0557:            }
0558:
0559:            public Component findComponentAt(Point p) {
0560:                toolkit.lockAWT();
0561:                try {
0562:                    return findComponentAt(p.x, p.y);
0563:                } finally {
0564:                    toolkit.unlockAWT();
0565:                }
0566:            }
0567:
0568:            public Component findComponentAt(int x, int y) {
0569:                toolkit.lockAWT();
0570:                try {
0571:                    if (!contains(x, y) || !isShowing()) {
0572:                        return null;
0573:                    }
0574:
0575:                    if (!getClient().contains(x, y)) {
0576:                        return this ;
0577:                    }
0578:
0579:                    Component c = null, fc = null;// = getComponentAt(x,y);
0580:                    // if c is not visible, get next component
0581:                    // under it, etc. So cannot actually use getComponentAt():
0582:                    // have to traverse children manually
0583:
0584:                    for (int i = 0; i < children.size(); i++) {
0585:                        c = children.get(i);
0586:                        if (!c.isVisible()) {
0587:                            continue;
0588:                        }
0589:                        if (c.contains(x - c.getX(), y - c.getY())) {
0590:                            fc = c;
0591:                            break;
0592:                        }
0593:                    }
0594:
0595:                    if (fc instanceof  Container) {
0596:                        fc = ((Container) fc).findComponentAt(x - fc.getX(), y
0597:                                - fc.getY());
0598:                    }
0599:
0600:                    if (fc == null) {
0601:                        fc = this ;
0602:                    }
0603:                    return fc;
0604:                } finally {
0605:                    toolkit.unlockAWT();
0606:                }
0607:            }
0608:
0609:            @Override
0610:            public float getAlignmentX() {
0611:                toolkit.lockAWT();
0612:                try {
0613:                    if ((layout != null)
0614:                            && (LayoutManager2.class.isInstance(layout))) {
0615:                        return ((LayoutManager2) layout)
0616:                                .getLayoutAlignmentX(this );
0617:                    }
0618:
0619:                    return super .getAlignmentX();
0620:                } finally {
0621:                    toolkit.unlockAWT();
0622:                }
0623:            }
0624:
0625:            @Override
0626:            public float getAlignmentY() {
0627:                toolkit.lockAWT();
0628:                try {
0629:                    if ((layout != null)
0630:                            && (LayoutManager2.class.isInstance(layout))) {
0631:                        return ((LayoutManager2) layout)
0632:                                .getLayoutAlignmentY(this );
0633:                    }
0634:
0635:                    return super .getAlignmentY();
0636:                } finally {
0637:                    toolkit.unlockAWT();
0638:                }
0639:            }
0640:
0641:            public Component getComponent(int n)
0642:                    throws ArrayIndexOutOfBoundsException {
0643:                toolkit.lockAWT();
0644:                try {
0645:                    return children.get(n);
0646:                } finally {
0647:                    toolkit.unlockAWT();
0648:                }
0649:            }
0650:
0651:            @Override
0652:            public Component getComponentAt(Point p) {
0653:                toolkit.lockAWT();
0654:                try {
0655:                    return getComponentAt(p.x, p.y);
0656:                } finally {
0657:                    toolkit.unlockAWT();
0658:                }
0659:            }
0660:
0661:            @Override
0662:            public Component getComponentAt(int x, int y) {
0663:                toolkit.lockAWT();
0664:                try {
0665:                    return locate(x, y);
0666:                } finally {
0667:                    toolkit.unlockAWT();
0668:                }
0669:            }
0670:
0671:            public int getComponentCount() {
0672:                toolkit.lockAWT();
0673:                try {
0674:                    return countComponents();
0675:                } finally {
0676:                    toolkit.unlockAWT();
0677:                }
0678:            }
0679:
0680:            public Component[] getComponents() {
0681:                toolkit.lockAWT();
0682:                try {
0683:                    return children.toArray(new Component[0]);
0684:                } finally {
0685:                    toolkit.unlockAWT();
0686:                }
0687:            }
0688:
0689:            @Override
0690:            public Set<AWTKeyStroke> getFocusTraversalKeys(int id) {
0691:                toolkit.lockAWT();
0692:                try {
0693:                    return super .getFocusTraversalKeys(id);
0694:                } finally {
0695:                    toolkit.unlockAWT();
0696:                }
0697:            }
0698:
0699:            public FocusTraversalPolicy getFocusTraversalPolicy() {
0700:                toolkit.lockAWT();
0701:                try {
0702:                    if (isFocusTraversalPolicyProvider() || focusCycleRoot) {
0703:                        if (isFocusTraversalPolicySet()) {
0704:                            return focusTraversalPolicy;
0705:                        }
0706:                        Container root = getFocusCycleRootAncestor();
0707:                        return ((root != null) ? root.getFocusTraversalPolicy()
0708:                                : KeyboardFocusManager
0709:                                        .getCurrentKeyboardFocusManager()
0710:                                        .getDefaultFocusTraversalPolicy());
0711:                    }
0712:                    return null;
0713:                } finally {
0714:                    toolkit.unlockAWT();
0715:                }
0716:            }
0717:
0718:            @Override
0719:            public Insets getInsets() {
0720:                toolkit.lockAWT();
0721:                try {
0722:                    return insets();
0723:                } finally {
0724:                    toolkit.unlockAWT();
0725:                }
0726:            }
0727:
0728:            public LayoutManager getLayout() {
0729:                toolkit.lockAWT();
0730:                try {
0731:                    return layout;
0732:                } finally {
0733:                    toolkit.unlockAWT();
0734:                }
0735:            }
0736:
0737:            Dimension addInsets(Dimension size) {
0738:                Insets insets = getInsets();
0739:                size.width += insets.left + insets.right;
0740:                size.height += insets.top + insets.bottom;
0741:
0742:                return size;
0743:            }
0744:
0745:            Rectangle getClient() {
0746:                Insets insets = getInsets();
0747:                return new Rectangle(insets.left, insets.top, w - insets.right
0748:                        - insets.left, h - insets.top - insets.bottom);
0749:            }
0750:
0751:            @Override
0752:            public Dimension getMinimumSize() {
0753:                toolkit.lockAWT();
0754:                try {
0755:                    return minimumSize();
0756:                } finally {
0757:                    toolkit.unlockAWT();
0758:                }
0759:            }
0760:
0761:            /**
0762:             * @deprecated
0763:             */
0764:            @SuppressWarnings("deprecation")
0765:            @Deprecated
0766:            @Override
0767:            public Dimension minimumSize() {
0768:                toolkit.lockAWT();
0769:                try {
0770:                    return super .minimumSize();
0771:                } finally {
0772:                    toolkit.unlockAWT();
0773:                }
0774:            }
0775:
0776:            @Override
0777:            Dimension getDefaultMinimumSize() {
0778:                if (layout == null) {
0779:                    return null;
0780:                }
0781:                if (minimumLayoutSize == null) {
0782:                    minimumLayoutSize = layout.minimumLayoutSize(this );
0783:                }
0784:                return minimumLayoutSize;
0785:            }
0786:
0787:            @Override
0788:            public Dimension getPreferredSize() {
0789:                toolkit.lockAWT();
0790:                try {
0791:                    return preferredSize();
0792:                } finally {
0793:                    toolkit.unlockAWT();
0794:                }
0795:            }
0796:
0797:            /**
0798:             * @deprecated
0799:             */
0800:            @SuppressWarnings("deprecation")
0801:            @Deprecated
0802:            @Override
0803:            public Dimension preferredSize() {
0804:                toolkit.lockAWT();
0805:                try {
0806:                    return super .preferredSize();
0807:                } finally {
0808:                    toolkit.unlockAWT();
0809:                }
0810:            }
0811:
0812:            @Override
0813:            Dimension getDefaultPreferredSize() {
0814:                if (layout == null) {
0815:                    return null;
0816:                }
0817:                if (preferredLayoutSize == null) {
0818:                    preferredLayoutSize = layout.preferredLayoutSize(this );
0819:                }
0820:                return preferredLayoutSize;
0821:            }
0822:
0823:            @Override
0824:            public Dimension getMaximumSize() {
0825:                toolkit.lockAWT();
0826:                try {
0827:                    if (!isMaximumSizeSet() && (layout != null)
0828:                            && (layout instanceof  LayoutManager2)) {
0829:                        return ((LayoutManager2) layout)
0830:                                .maximumLayoutSize(this );
0831:                    }
0832:                    return super .getMaximumSize();
0833:                } finally {
0834:                    toolkit.unlockAWT();
0835:                }
0836:            }
0837:
0838:            @Override
0839:            void resetDefaultSize() {
0840:                minimumLayoutSize = null;
0841:                preferredLayoutSize = null;
0842:
0843:                for (int i = 0; i < children.size(); i++) {
0844:                    Component c = children.get(i);
0845:                    c.resetDefaultSize();
0846:                }
0847:            }
0848:
0849:            /**
0850:             * @deprecated
0851:             */
0852:            @Deprecated
0853:            public Insets insets() {
0854:                toolkit.lockAWT();
0855:                try {
0856:                    return getNativeInsets();
0857:                } finally {
0858:                    toolkit.unlockAWT();
0859:                }
0860:            }
0861:
0862:            public boolean isAncestorOf(Component c) {
0863:                toolkit.lockAWT();
0864:                try {
0865:                    if (c == null || c instanceof  Window) {
0866:                        return false;
0867:                    }
0868:                    Container parent = c.parent;
0869:                    while (parent != null) {
0870:                        if (parent == this ) {
0871:                            return true;
0872:                        }
0873:                        if (parent instanceof  Window) {
0874:                            return false;
0875:                        }
0876:                        parent = parent.parent;
0877:                    }
0878:                    return false;
0879:                } finally {
0880:                    toolkit.unlockAWT();
0881:                }
0882:            }
0883:
0884:            @Override
0885:            public boolean isFocusCycleRoot(Container container) {
0886:                toolkit.lockAWT();
0887:                try {
0888:                    if (focusCycleRoot && container == this ) {
0889:                        return true;
0890:                    }
0891:                    return super .isFocusCycleRoot(container);
0892:                } finally {
0893:                    toolkit.unlockAWT();
0894:                }
0895:            }
0896:
0897:            public boolean isFocusCycleRoot() {
0898:                toolkit.lockAWT();
0899:                try {
0900:                    return focusCycleRoot;
0901:                } finally {
0902:                    toolkit.unlockAWT();
0903:                }
0904:            }
0905:
0906:            public boolean isFocusTraversalPolicySet() {
0907:                toolkit.lockAWT();
0908:                try {
0909:                    return focusTraversalPolicy != null;
0910:                } finally {
0911:                    toolkit.unlockAWT();
0912:                }
0913:            }
0914:
0915:            @Deprecated
0916:            @Override
0917:            @SuppressWarnings("deprecation")
0918:            public void layout() {
0919:                toolkit.lockAWT();
0920:                try {
0921:                    if (layout != null) {
0922:                        layout.layoutContainer(this );
0923:                    }
0924:                } finally {
0925:                    toolkit.unlockAWT();
0926:                }
0927:            }
0928:
0929:            @Deprecated
0930:            @Override
0931:            @SuppressWarnings("deprecation")
0932:            public Component locate(int x, int y) {
0933:                toolkit.lockAWT();
0934:                try {
0935:                    return locateImpl(x, y);
0936:                } finally {
0937:                    toolkit.unlockAWT();
0938:                }
0939:            }
0940:
0941:            Component locateImpl(int x, int y) {
0942:                // return topmost child containing point - search from index 0
0943:                for (int i = 0; i < children.size(); i++) {
0944:                    Component c = children.get(i);
0945:                    if (c.contains(x - c.getX(), y - c.getY())) {
0946:                        return c;
0947:                    }
0948:                }
0949:                if (contains(x, y)) {
0950:                    return this ;
0951:                }
0952:                return null;
0953:            }
0954:
0955:            @Override
0956:            void setRedrawManager() {
0957:                super .setRedrawManager();
0958:                for (int i = 0; i < children.size(); i++) {
0959:                    children.get(i).setRedrawManager();
0960:                }
0961:            }
0962:
0963:            @Override
0964:            public void paint(Graphics g) {
0965:                toolkit.lockAWT();
0966:                try {
0967:                    paintComponentsImpl(g);
0968:                } finally {
0969:                    toolkit.unlockAWT();
0970:                }
0971:            }
0972:
0973:            void propagateRepaint(long tm, int x, int y, int width, int height) {
0974:                for (int i = 0; i < children.size(); i++) {
0975:                    Component comp = children.get(i);
0976:
0977:                    if (comp.isLightweight()) {
0978:                        comp.repaint(tm, x - comp.x, y - comp.y, width, height);
0979:                    }
0980:                }
0981:            }
0982:
0983:            @Override
0984:            protected String paramString() {
0985:                /*
0986:                 * The format is based on 1.5 release behavior which can be revealed by
0987:                 * the following code:
0988:                 * 
0989:                 * Container container = new Container(); container.setLayout(new
0990:                 * FlowLayout()); System.out.println(container);
0991:                 */
0992:
0993:                toolkit.lockAWT();
0994:                try {
0995:                    return super .paramString()
0996:                            + (!isValid() ? ",invalid" : "") //$NON-NLS-1$ //$NON-NLS-2$
0997:                            + (layout != null ? ",layout=" + layout.getClass().getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$
0998:                } finally {
0999:                    toolkit.unlockAWT();
1000:                }
1001:            }
1002:
1003:            public void printComponents(Graphics g) {
1004:                toolkit.lockAWT();
1005:                try {
1006:                    paintComponents(g);
1007:                } finally {
1008:                    toolkit.unlockAWT();
1009:                }
1010:            }
1011:
1012:            public void paintComponents(Graphics g) {
1013:                toolkit.lockAWT();
1014:                try {
1015:                    paintComponentsImpl(g);
1016:                } finally {
1017:                    toolkit.unlockAWT();
1018:                }
1019:            }
1020:
1021:            private void paintComponentsImpl(Graphics g) {
1022:                Shape clip;
1023:
1024:                if ((!isShowing()) || (g == null)) {
1025:                    return;
1026:                }
1027:
1028:                clip = g.getClip();
1029:
1030:                for (int i = children.size() - 1; i >= 0; i--) {
1031:                    Component comp = children.get(i);
1032:
1033:                    if (comp.isLightweight() && comp.isVisible()) {
1034:                        if ((clip != null)
1035:                                && !clip.intersects(comp.getBounds())) {
1036:                            continue;
1037:                        }
1038:
1039:                        Graphics compGr = getComponentGraphics(g, comp);
1040:                        comp.paint(compGr);
1041:                        compGr.dispose();
1042:                    }
1043:                }
1044:            }
1045:
1046:            private Graphics getComponentGraphics(Graphics parent, Component c) {
1047:                Graphics g = parent.create(c.x, c.y, c.w, c.h);
1048:                g.setFont(c.getFont());
1049:                g.setColor(c.getForeground());
1050:                return g;
1051:            }
1052:
1053:            @Override
1054:            public void removeNotify() {
1055:                toolkit.lockAWT();
1056:                try {
1057:                    isRemoved = true;
1058:                    // moveFocusOnHide();
1059:                    for (int i = 0; i < children.size(); i++) {
1060:                        children.get(i).removeNotify();
1061:                    }
1062:                    super .removeNotify();
1063:                } finally {
1064:                    isRemoved = false;
1065:                    toolkit.unlockAWT();
1066:                }
1067:            }
1068:
1069:            public void setFocusCycleRoot(boolean b) {
1070:                boolean wasFocusCycleRoot;
1071:                toolkit.lockAWT();
1072:                try {
1073:                    wasFocusCycleRoot = focusCycleRoot;
1074:                    focusCycleRoot = b;
1075:                } finally {
1076:                    toolkit.unlockAWT();
1077:                }
1078:                firePropertyChange(
1079:                        "focusCycleRoot", wasFocusCycleRoot, focusCycleRoot); //$NON-NLS-1$
1080:            }
1081:
1082:            @Override
1083:            public void setFocusTraversalKeys(int id,
1084:                    Set<? extends AWTKeyStroke> keystrokes) {
1085:                toolkit.lockAWT();
1086:                try {
1087:                    super .setFocusTraversalKeys(id, keystrokes);
1088:                } finally {
1089:                    toolkit.unlockAWT();
1090:                }
1091:            }
1092:
1093:            public void setFocusTraversalPolicy(FocusTraversalPolicy policy) {
1094:                FocusTraversalPolicy oldPolicy;
1095:                toolkit.lockAWT();
1096:                try {
1097:                    oldPolicy = focusTraversalPolicy;
1098:                    focusTraversalPolicy = policy;
1099:                } finally {
1100:                    toolkit.unlockAWT();
1101:                }
1102:                firePropertyChange("focusTraversalPolicy", oldPolicy, policy); //$NON-NLS-1$
1103:            }
1104:
1105:            @Override
1106:            public void setFont(Font f) {
1107:                toolkit.lockAWT();
1108:                try {
1109:                    super .setFont(f);
1110:                } finally {
1111:                    toolkit.unlockAWT();
1112:                }
1113:            }
1114:
1115:            @Override
1116:            void setFontImpl(Font f) {
1117:                super .setFontImpl(f);
1118:
1119:                for (int i = 0; i < children.size(); i++) {
1120:                    children.get(i).propagateFont();
1121:                }
1122:            }
1123:
1124:            @Override
1125:            boolean propagateFont() {
1126:                if (!super .propagateFont()) {
1127:                    return false;
1128:                }
1129:
1130:                for (int i = 0; i < children.size(); i++) {
1131:                    children.get(i).propagateFont();
1132:                }
1133:                return true;
1134:            }
1135:
1136:            public void setLayout(LayoutManager mgr) {
1137:                toolkit.lockAWT();
1138:                try {
1139:                    if (layout != null) {
1140:                        for (Component component : children) {
1141:                            layout.removeLayoutComponent(component);
1142:                        }
1143:                    }
1144:
1145:                    if (mgr != null) {
1146:                        for (Component component : children) {
1147:                            mgr.addLayoutComponent(null, component);
1148:                        }
1149:                    }
1150:
1151:                    layout = mgr;
1152:                    invalidate();
1153:                } finally {
1154:                    toolkit.unlockAWT();
1155:                }
1156:            }
1157:
1158:            @Override
1159:            public void transferFocusBackward() {
1160:                toolkit.lockAWT();
1161:                try {
1162:                    super .transferFocusBackward(); // TODO: why override?
1163:                } finally {
1164:                    toolkit.unlockAWT();
1165:                }
1166:            }
1167:
1168:            public void transferFocusDownCycle() {
1169:                toolkit.lockAWT();
1170:                try {
1171:                    if (isFocusCycleRoot()) {
1172:                        KeyboardFocusManager kfm = KeyboardFocusManager
1173:                                .getCurrentKeyboardFocusManager();
1174:                        Container root = kfm.getCurrentFocusCycleRoot();
1175:                        FocusTraversalPolicy policy = getFocusTraversalPolicy();
1176:                        if (root != this ) {
1177:                            root = this ;
1178:                            kfm.setGlobalCurrentFocusCycleRoot(root);
1179:
1180:                        }
1181:                        policy.getDefaultComponent(root).requestFocus();
1182:                    }
1183:                } finally {
1184:                    toolkit.unlockAWT();
1185:                }
1186:            }
1187:
1188:            @Override
1189:            public void invalidate() {
1190:                toolkit.lockAWT();
1191:                try {
1192:                    super .invalidate();
1193:                    if ((layout != null)
1194:                            && LayoutManager2.class.isInstance(layout)) {
1195:                        ((LayoutManager2) layout).invalidateLayout(this );
1196:                    }
1197:                } finally {
1198:                    toolkit.unlockAWT();
1199:                }
1200:            }
1201:
1202:            @Override
1203:            public void validate() {
1204:                toolkit.lockAWT();
1205:                try {
1206:                    if (isValid() || !behaviour.isDisplayable()) {
1207:                        return;
1208:                    }
1209:
1210:                    doLayout();
1211:                    validateTree();
1212:                    super .validate();
1213:
1214:                } finally {
1215:                    toolkit.unlockAWT();
1216:                }
1217:            }
1218:
1219:            protected void validateTree() {
1220:                toolkit.lockAWT();
1221:                try {
1222:                    for (int i = 0; i < children.size(); i++) {
1223:                        Component c = children.get(i);
1224:                        if (!c.isValid()) {
1225:                            c.validate();
1226:                        }
1227:                    }
1228:                } finally {
1229:                    toolkit.unlockAWT();
1230:                }
1231:            }
1232:
1233:            @Override
1234:            void mapToDisplay(boolean b) {
1235:                super .mapToDisplay(b);
1236:                // map to display from bottom to top, to get right initial Z-order
1237:                for (int i = children.size() - 1; i >= 0; i--) {
1238:                    children.get(i).mapToDisplay(b);
1239:                }
1240:            }
1241:
1242:            @Override
1243:            void moveFocusOnHide() {
1244:                Component focusOwner = KeyboardFocusManager
1245:                        .getCurrentKeyboardFocusManager().getFocusOwner();
1246:                if (focusOwner != null && isAncestorOf(focusOwner)) {
1247:                    focusOwner.moveFocus();
1248:                }
1249:                super .moveFocus();
1250:            }
1251:
1252:            @Override
1253:            void prepareChildren4HierarchyChange() {
1254:                for (int i = 0; i < children.size(); i++) {
1255:                    children.get(i).prepare4HierarchyChange();
1256:                }
1257:            }
1258:
1259:            @Override
1260:            void finishChildrenHierarchyChange(Component changed,
1261:                    Container changedParent, int ancestorFlags) {
1262:                for (int i = 0; i < children.size(); i++) {
1263:                    children.get(i).finishHierarchyChange(changed,
1264:                            changedParent, ancestorFlags);
1265:                }
1266:            }
1267:
1268:            @Override
1269:            void postHierarchyBoundsEvents(Component changed, int id) {
1270:                super .postHierarchyBoundsEvents(changed, id);
1271:
1272:                spreadHierarchyBoundsEvents(changed, id);
1273:            }
1274:
1275:            @Override
1276:            void spreadHierarchyBoundsEvents(Component changed, int id) {
1277:                for (int i = 0; i < children.size(); i++) {
1278:                    children.get(i).postHierarchyBoundsEvents(changed, id);
1279:                }
1280:            }
1281:
1282:            public ContainerListener[] getContainerListeners() {
1283:                // toolkit.lockAWT();
1284:                // try {
1285:                return containerListeners
1286:                        .getUserListeners(new ContainerListener[0]);
1287:                // } finally {
1288:                // toolkit.unlockAWT();
1289:                // }
1290:            }
1291:
1292:            public void addContainerListener(ContainerListener l) {
1293:                // toolkit.lockAWT();
1294:                // try {
1295:                containerListeners.addUserListener(l);
1296:                // } finally {
1297:                // toolkit.unlockAWT();
1298:                // }
1299:            }
1300:
1301:            public void removeContainerListener(ContainerListener l) {
1302:                // toolkit.lockAWT();
1303:                // try {
1304:                containerListeners.removeUserListener(l);
1305:                // } finally {
1306:                // toolkit.unlockAWT();
1307:                // }
1308:            }
1309:
1310:            @SuppressWarnings("unchecked")
1311:            @Override
1312:            public <T extends EventListener> T[] getListeners(
1313:                    Class<T> listenerType) {
1314:                // toolkit.lockAWT();
1315:                // try {
1316:                if (ContainerListener.class.isAssignableFrom(listenerType)) {
1317:                    return (T[]) getContainerListeners();
1318:                }
1319:                return super .getListeners(listenerType);
1320:                // } finally {
1321:                // toolkit.unlockAWT();
1322:                // }
1323:            }
1324:
1325:            @Override
1326:            protected void processEvent(AWTEvent e) {
1327:                // toolkit.lockAWT();
1328:                // try {
1329:                if (toolkit.eventTypeLookup.getEventMask(e) == AWTEvent.CONTAINER_EVENT_MASK) {
1330:                    processContainerEvent((ContainerEvent) e);
1331:                } else {
1332:                    super .processEvent(e);
1333:                }
1334:                // } finally {
1335:                // toolkit.unlockAWT();
1336:                // }
1337:            }
1338:
1339:            protected void processContainerEvent(ContainerEvent e) {
1340:                // toolkit.lockAWT();
1341:                // try {
1342:                for (Iterator<?> i = containerListeners.getUserIterator(); i
1343:                        .hasNext();) {
1344:                    ContainerListener listener = (ContainerListener) i.next();
1345:
1346:                    switch (e.getID()) {
1347:                    case ContainerEvent.COMPONENT_ADDED:
1348:                        listener.componentAdded(e);
1349:                        break;
1350:                    case ContainerEvent.COMPONENT_REMOVED:
1351:                        listener.componentRemoved(e);
1352:                        break;
1353:                    }
1354:                }
1355:                // } finally {
1356:                // toolkit.unlockAWT();
1357:                // }
1358:            }
1359:
1360:            /**
1361:             * Determine if comp contains point pos. Comp must be showing and top-most
1362:             * component in Z-order.
1363:             * 
1364:             * @param comp component to look for
1365:             * @param pos point to look component at
1366:             * 
1367:             * @return
1368:             */
1369:            boolean isComponentAt(Component comp, Point pos) {
1370:                toolkit.lockAWT();
1371:                try {
1372:                    Point p = new Point(pos);
1373:                    Container container = this ;
1374:                    Component c = null, fc = null;
1375:                    if (!contains(p) || !isShowing()) {
1376:                        return false;
1377:                    }
1378:                    while (container != null) {
1379:                        if (!container.getClient().contains(p)) {
1380:                            return false;
1381:                        }
1382:
1383:                        Vector<Component> children = container.children;
1384:                        for (int i = 0; i < children.size(); i++) {
1385:                            c = children.get(i);
1386:                            if (!c.isVisible()) {
1387:                                continue;
1388:                            }
1389:                            if (c.contains(p.x - c.getX(), p.y - c.getY())) {
1390:                                fc = c;
1391:                                break;
1392:                            }
1393:                        }
1394:
1395:                        if ((fc == comp) || (container == c)
1396:                                || (fc == container)) {
1397:                            break;
1398:                        }
1399:
1400:                        if (fc instanceof  Container) {
1401:                            p.translate(-fc.getX(), -fc.getY());
1402:                            container = (Container) fc;
1403:                        } else {
1404:                            container = null;
1405:                        }
1406:
1407:                    }
1408:
1409:                    if (fc == null) {
1410:                        fc = this ;
1411:                    }
1412:                    return (fc == comp);
1413:                } finally {
1414:                    toolkit.unlockAWT();
1415:                }
1416:            }
1417:
1418:            public Point getMousePosition(boolean allowChildren)
1419:                    throws HeadlessException {
1420:                toolkit.lockAWT();
1421:                try {
1422:                    Point pos = getMousePosition();
1423:                    if ((pos != null) && !allowChildren) {
1424:                        // check that there's no [visible] child
1425:                        // containing point pos:
1426:                        Component child = findComponentAt(pos);
1427:                        if (child != this ) {
1428:                            pos = null;
1429:                        }
1430:                    }
1431:                    return pos;
1432:                } finally {
1433:                    toolkit.unlockAWT();
1434:                }
1435:            }
1436:
1437:            public final boolean isFocusTraversalPolicyProvider() {
1438:                return focusTraversalPolicyProvider;
1439:            }
1440:
1441:            public final void setFocusTraversalPolicyProvider(boolean provider) {
1442:                boolean wasProvider;
1443:                toolkit.lockAWT();
1444:                try {
1445:                    wasProvider = focusTraversalPolicyProvider;
1446:                    focusTraversalPolicyProvider = provider;
1447:                } finally {
1448:                    toolkit.unlockAWT();
1449:                }
1450:                firePropertyChange("focusTraversalPolicyProvider", wasProvider, //$NON-NLS-1$
1451:                        focusTraversalPolicyProvider);
1452:            }
1453:
1454:            /**
1455:             * Find which focus cycle root to take when doing keyboard focus traversal
1456:             * and focus owner is a container & focus cycle root itself.
1457:             * 
1458:             * @return
1459:             */
1460:            Container getFocusTraversalRoot() {
1461:                KeyboardFocusManager kfm = KeyboardFocusManager
1462:                        .getCurrentKeyboardFocusManager();
1463:                Container root = kfm.getCurrentFocusCycleRoot();
1464:                Container container = this ;
1465:                while ((root != container) && (container != null)) {
1466:                    container = container.getFocusCycleRootAncestor();
1467:                }
1468:                return (container == root) ? root : null;
1469:            }
1470:
1471:            /**
1472:             * Adds parts obscured by components which
1473:             * are above the given component
1474:             * in this container to mra
1475:             * @param mra MultiRectArea to add regions to
1476:             * @param component obscured regions of this component are added
1477:             */
1478:            void addObscuredRegions(MultiRectArea mra, Component component) {
1479:                int z = getComponentZOrder(component);
1480:                int i;
1481:                for (i = 0; i < z; i++) {
1482:                    Component comp = getComponent(i);
1483:                    if (comp.isDisplayable() && comp.isVisible()
1484:                            && comp.isOpaque()) {
1485:                        mra.add(comp.getBounds());
1486:                    }
1487:                }
1488:                for (i = z + 1; i < getComponentCount(); i++) {
1489:                    Component comp = getComponent(i);
1490:                    if (comp.isVisible() && !comp.isLightweight()) {
1491:                        mra.add(comp.getBounds());
1492:                    }
1493:                }
1494:            }
1495:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.