< prev index next >

src/java.desktop/share/classes/java/awt/Container.java

Print this page




 515      * Checks :  index in bounds of container's size,
 516      * comp is not one of this container's parents,
 517      * and comp is not a window.
 518      * Comp and container must be on the same GraphicsDevice.
 519      * if comp is container, all sub-components must be on
 520      * same GraphicsDevice.
 521      *
 522      * @since 1.5
 523      */
 524     private void checkAdding(Component comp, int index) {
 525         checkTreeLock();
 526 
 527         GraphicsConfiguration thisGC = getGraphicsConfiguration();
 528 
 529         if (index > component.size() || index < 0) {
 530             throw new IllegalArgumentException("illegal component position");
 531         }
 532         if (comp.parent == this) {
 533             if (index == component.size()) {
 534                 throw new IllegalArgumentException("illegal component position " +
 535                                                    index + " should be less then " + component.size());
 536             }
 537         }
 538         checkAddToSelf(comp);
 539         checkNotAWindow(comp);
 540 
 541         Window thisTopLevel = getContainingWindow();
 542         Window compTopLevel = comp.getContainingWindow();
 543         if (thisTopLevel != compTopLevel) {
 544             throw new IllegalArgumentException("component and container should be in the same top-level window");
 545         }
 546         if (thisGC != null) {
 547             comp.checkGD(thisGC.getDevice().getIDstring());
 548         }
 549     }
 550 
 551     /**
 552      * Removes component comp from this container without making unnecessary changes
 553      * and generating unnecessary events. This function intended to perform optimized
 554      * remove, for example, if newParent and current parent are the same it just changes
 555      * index without calling removeNotify.




 515      * Checks :  index in bounds of container's size,
 516      * comp is not one of this container's parents,
 517      * and comp is not a window.
 518      * Comp and container must be on the same GraphicsDevice.
 519      * if comp is container, all sub-components must be on
 520      * same GraphicsDevice.
 521      *
 522      * @since 1.5
 523      */
 524     private void checkAdding(Component comp, int index) {
 525         checkTreeLock();
 526 
 527         GraphicsConfiguration thisGC = getGraphicsConfiguration();
 528 
 529         if (index > component.size() || index < 0) {
 530             throw new IllegalArgumentException("illegal component position");
 531         }
 532         if (comp.parent == this) {
 533             if (index == component.size()) {
 534                 throw new IllegalArgumentException("illegal component position " +
 535                                                    index + " should be less than " + component.size());
 536             }
 537         }
 538         checkAddToSelf(comp);
 539         checkNotAWindow(comp);
 540 
 541         Window thisTopLevel = getContainingWindow();
 542         Window compTopLevel = comp.getContainingWindow();
 543         if (thisTopLevel != compTopLevel) {
 544             throw new IllegalArgumentException("component and container should be in the same top-level window");
 545         }
 546         if (thisGC != null) {
 547             comp.checkGD(thisGC.getDevice().getIDstring());
 548         }
 549     }
 550 
 551     /**
 552      * Removes component comp from this container without making unnecessary changes
 553      * and generating unnecessary events. This function intended to perform optimized
 554      * remove, for example, if newParent and current parent are the same it just changes
 555      * index without calling removeNotify.


< prev index next >