(Container target)
| 196 | |
| 197 | |
| 198 | @Override |
| 199 | public void layoutContainer(Container target) { |
| 200 | Insets insets = target.getInsets(); |
| 201 | Rectangle bounds = target.getBounds(); |
| 202 | int maxheight = bounds.height - insets.bottom; |
| 203 | int compCnt = target.getComponentCount(); |
| 204 | int y = insets.top; |
| 205 | int x = insets.left; |
| 206 | int rowWidth = 0; |
| 207 | |
| 208 | for (int i = 0; i < compCnt; i++) { |
| 209 | Component comp = target.getComponent(i); |
| 210 | if (comp.isVisible()) { |
| 211 | Dimension d = comp.getPreferredSize(); |
| 212 | comp.setSize(d); |
| 213 | if (y + d.height <= maxheight) { |
| 214 | comp.setLocation(x, y); |
| 215 | y += d.height; |
| 216 | rowWidth = Math.max(rowWidth, d.width); |
| 217 | } |
| 218 | else { |
| 219 | //we need to start a new column |
| 220 | x += rowWidth; |
| 221 | rowWidth = 0; |
| 222 | y = insets.top; |
| 223 | comp.setLocation(x, y); |
| 224 | y += d.height; |
| 225 | rowWidth = Math.max(rowWidth, d.width); |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | public int getColumnForComponentIndex(int index) { |
| 232 | return columnForComponentIndex[index]; |
nothing calls this directly
no test coverage detected