1092 * @see LayoutManager2 1093 * @since 1.1 1094 */ 1095 protected void addImpl(Component comp, Object constraints, int index) { 1096 synchronized (getTreeLock()) { 1097 /* Check for correct arguments: index in bounds, 1098 * comp cannot be one of this container's parents, 1099 * and comp cannot be a window. 1100 * comp and container must be on the same GraphicsDevice. 1101 * if comp is container, all sub-components must be on 1102 * same GraphicsDevice. 1103 */ 1104 GraphicsConfiguration thisGC = this.getGraphicsConfiguration(); 1105 1106 if (index > component.size() || (index < 0 && index != -1)) { 1107 throw new IllegalArgumentException( 1108 "illegal component position"); 1109 } 1110 checkAddToSelf(comp); 1111 checkNotAWindow(comp); 1112 if (thisGC != null) { 1113 comp.checkGD(thisGC.getDevice().getIDstring()); 1114 } 1115 1116 /* Reparent the component and tidy up the tree's state. */ 1117 if (comp.parent != null) { 1118 comp.parent.remove(comp); 1119 if (index > component.size()) { 1120 throw new IllegalArgumentException("illegal component position"); 1121 } 1122 } 1123 1124 //index == -1 means add to the end. 1125 if (index == -1) { 1126 component.add(comp); 1127 } else { 1128 component.add(index, comp); 1129 } 1130 comp.parent = this; 1131 comp.setGraphicsConfiguration(thisGC); 1132 1133 adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK, 1134 comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK)); 1135 adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK, 1136 comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)); 1137 adjustDescendants(comp.countHierarchyMembers()); 1138 1139 invalidateIfValid(); 1140 if (peer != null) { 1141 comp.addNotify(); 1142 } | 1092 * @see LayoutManager2 1093 * @since 1.1 1094 */ 1095 protected void addImpl(Component comp, Object constraints, int index) { 1096 synchronized (getTreeLock()) { 1097 /* Check for correct arguments: index in bounds, 1098 * comp cannot be one of this container's parents, 1099 * and comp cannot be a window. 1100 * comp and container must be on the same GraphicsDevice. 1101 * if comp is container, all sub-components must be on 1102 * same GraphicsDevice. 1103 */ 1104 GraphicsConfiguration thisGC = this.getGraphicsConfiguration(); 1105 1106 if (index > component.size() || (index < 0 && index != -1)) { 1107 throw new IllegalArgumentException( 1108 "illegal component position"); 1109 } 1110 checkAddToSelf(comp); 1111 checkNotAWindow(comp); 1112 /* Reparent the component and tidy up the tree's state. */ 1113 if (comp.parent != null) { 1114 comp.parent.remove(comp); 1115 if (index > component.size()) { 1116 throw new IllegalArgumentException("illegal component position"); 1117 } 1118 } 1119 if (thisGC != null) { 1120 comp.checkGD(thisGC.getDevice().getIDstring()); 1121 } 1122 1123 1124 1125 //index == -1 means add to the end. 1126 if (index == -1) { 1127 component.add(comp); 1128 } else { 1129 component.add(index, comp); 1130 } 1131 comp.parent = this; 1132 comp.setGraphicsConfiguration(thisGC); 1133 1134 adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK, 1135 comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK)); 1136 adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK, 1137 comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)); 1138 adjustDescendants(comp.countHierarchyMembers()); 1139 1140 invalidateIfValid(); 1141 if (peer != null) { 1142 comp.addNotify(); 1143 } |