148 |
throw new AWTError("invalid parent"); |
throw new AWTError("invalid parent"); |
149 |
|
|
150 |
Insets insets = parent.getInsets(); |
Insets insets = parent.getInsets(); |
151 |
int x = insets.left + insets.right; |
int x = 0; |
152 |
int y = insets.bottom + insets.top; |
int y = 0; |
153 |
|
|
154 |
Component[] children = parent.getComponents(); |
Component[] children = parent.getComponents(); |
155 |
|
|
156 |
if (isHorizontalIn(parent)) |
if (isHorizontalIn(parent)) |
157 |
{ |
{ |
158 |
|
x = insets.left + insets.right; |
159 |
// sum up preferred widths of components, find maximum of preferred |
// sum up preferred widths of components, find maximum of preferred |
160 |
// heights |
// heights |
161 |
for (int index = 0; index < children.length; index++) |
for (int index = 0; index < children.length; index++) |
165 |
x += sz.width; |
x += sz.width; |
166 |
y = Math.max(y, sz.height); |
y = Math.max(y, sz.height); |
167 |
} |
} |
168 |
|
y += insets.bottom + insets.top; |
169 |
} |
} |
170 |
else |
else |
171 |
{ |
{ |
172 |
|
y = insets.top + insets.bottom; |
173 |
// sum up preferred heights of components, find maximum of |
// sum up preferred heights of components, find maximum of |
174 |
// preferred widths |
// preferred widths |
175 |
for (int index = 0; index < children.length; index++) |
for (int index = 0; index < children.length; index++) |
179 |
y += sz.height; |
y += sz.height; |
180 |
x = Math.max(x, sz.width); |
x = Math.max(x, sz.width); |
181 |
} |
} |
182 |
|
x += insets.left + insets.right; |
183 |
} |
} |
184 |
|
|
185 |
return new Dimension(x, y); |
return new Dimension(x, y); |
186 |
} |
} |
187 |
|
|