public void layoutContainer(Container parent) { int n = rows.size(); Insets border = parent.getInsets(); int lastY = border.top; // figure out where the second column should start int secondColumn = 0; for (int i = 0; i < n; i++) { Row r = (Row) rows.get(i); if (r instanceof NormalRow) { NormalRow nr = (NormalRow) r; secondColumn = Math.max( secondColumn, // nr.l.getMinimumSize().width); nr.getLabelWidth(false)); } } secondColumn += border.left + EXTRA; for (int i = 0; i < n; i++) { Row r = (Row) rows.get(i); if (r instanceof HeaderRow) { // header Component header = ((HeaderRow) r).h; int w = parent.getWidth() - (border.left + border.right); int h = header.getMinimumSize().height; int x = border.left; int y = lastY; header.setBounds(x, y, w, h); lastY += h; } else if (r instanceof NormalRow) { // label JLabel l = (JLabel) ((NormalRow) r).l; int w1 = l.getMinimumSize().width; // int h1 = l.getPreferredSize().height; int h1 = l.getMinimumSize().height; int x1 = secondColumn - w1; int y1 = lastY; l.setBounds(x1, y1, w1, h1); // control Component c = ((NormalRow) r).c; // WAS: int w2 = c.getPreferredSize().width; int w2 = c.getMaximumSize().width; // NEW! w2 = Math.min(w2, parent.getWidth() - (border.right + PADDING + secondColumn)); int h2 = c.getPreferredSize().height; int x2 = secondColumn + PADDING; // buffer between 'em int y2 = lastY; c.setBounds(x2, y2, w2, h2); lastY += Math.max(h1, h2); } } // focus on the first one? (is that my job?) (is it even possible?) }
public void layoutContainer(Container parent) { Dimension ourSize = preferredLayoutSize(parent), // Does the following do something useful? // And shouldn't we cater to real instead of maximum sizes? // This way, if a VerticallyLaidout component had a particular size forced upon it, // wouldn't we neglect to scale down to using minimum sizes so long as its maximum // size was bigger than our preferred? all: [Davis] maxSize = parent.getMaximumSize(), size = parent.getSize(); Insets isets = parent.getInsets(); Dimension compSize; int n = parent.getComponentCount(); int y; boolean usingPreferredSize = true; if (ourSize.width > maxSize.width || ourSize.height > maxSize.height) { ourSize = minimumLayoutSize(parent); usingPreferredSize = false; } switch (verticalAlignment) { case TOP: y = isets.top; break; case BOTTOM: y = (size.height - ourSize.height); break; default: // assume MIDDLE y = (size.height - ourSize.height) / 2 + isets.top; break; } for (int i = 0; i < n; i++) { Component c = parent.getComponent(i); compSize = usingPreferredSize ? c.getPreferredSize() : c.getMinimumSize(); switch (horizontalAlignment) { case LEFT: c.setBounds(isets.left, y, compSize.width, compSize.height); break; case RIGHT: c.setBounds( ourSize.width - isets.right - compSize.width + isets.left, y, compSize.width, compSize.height); break; default: // assume CENTER c.setBounds( (ourSize.width - isets.left - isets.right - compSize.width + isets.left) / 2, y, compSize.width, compSize.height); } y += compSize.height + vgap; } }
/** Lays out the container in the specified panel. */ public void layoutContainer(Container target) { synchronized (target.getTreeLock()) { Insets insets = target.getInsets(); Dimension dim = target.getSize(); int fullHeight = dim.height; int bottom = dim.height - insets.bottom - 1; int top = 0 + insets.top; int left = insets.left; int maxPosition = dim.width - (insets.left + insets.right) - hgap; int right = dim.width - insets.right; maxPosition = right; int height = bottom - top; int size = actions.size(); int w, h; if ((grip != null) && grip.isVisible()) { Dimension d = grip.getPreferredSize(); grip.setBounds(left, top + vgap, d.width, bottom - top - 2 * vgap); left += d.width; left += hgap; } for (int i = 0; i < size; i++) { left += hgap; Component comp = (Component) actions.elementAt(i); Dimension d; Dimension minSize = comp.getMinimumSize(); if (i == size - 1) d = comp.getMaximumSize(); else d = comp.getPreferredSize(); w = d.width; h = Math.min(height, d.height); if ((left < maxPosition) && (left + w > maxPosition)) { if (maxPosition - left >= minSize.width) w = maxPosition - left; } comp.setBounds(left, (fullHeight - d.height) / 2, w, h); // if (i == size - 1) // d = comp.getMaximumSize(); // else // d = comp.getPreferredSize(); // if ((left + d.width) > right) // w = right - left; // else // w = d.width; // h = Math.min (height, d.height); // comp.setBounds (left, (fullHeight - d.height)/2, w, h); left += d.width; } } }
public void layoutContainer(Container parent) { Insets insets = parent.getInsets(); int maxWidth = parent.getSize().width - (insets.left + insets.right); int maxHeight = parent.getSize().height - (insets.top + insets.bottom); int nComps = parent.getComponentCount(); if (this.sizeUnknown) { setSizes(parent); } Component c; if (nComps < 2) { c = parent.getComponent(0); if (c.isVisible()) { Dimension d = c.getPreferredSize(); c.setBounds(0, 0, d.width, d.height); return; } return; } double radialCurrent = Math.toRadians(SpiderWebPlot.DEFAULT_START_ANGLE); double radialIncrement = 6.283185307179586d / ((double) nComps); int midX = maxWidth / 2; int midY = maxHeight / 2; int a = midX - this.maxCompWidth; int b = midY - this.maxCompHeight; for (int i = 0; i < nComps; i++) { c = parent.getComponent(i); if (c.isVisible()) { d = c.getPreferredSize(); double d2 = (double) midX; double d3 = (double) a; int x = (int) (((r0 - (r0 * Math.cos(radialCurrent))) - (d.getWidth() / DateAxis.DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS)) + ((double) insets.left)); d2 = (double) midY; d3 = (double) b; c.setBounds( x, (int) (((r0 - (r0 * Math.sin(radialCurrent))) - (d.getHeight() / DateAxis.DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS)) + ((double) insets.top)), d.width, d.height); } radialCurrent += radialIncrement; } }
public void componentMoved(ComponentEvent evt) { Component component = evt.getComponent(); Point point = component.getLocation(); if (point.y < 0) { component.setBounds(point.x, 0, component.getWidth(), component.getHeight()); } }
public void layoutContainer(Container target) { Insets insets = target.getInsets(); int ncomponents = target.getComponentCount(); int top = 0; int left = insets.left; Dimension tps = target.getPreferredSize(); Dimension targetSize = target.getSize(); Component comp; Dimension ps; if (horizontalOrientation == Orientation.CENTER) left = left + (targetSize.width / 2) - (tps.width / 2); if (horizontalOrientation == Orientation.RIGHT) left = left + targetSize.width - tps.width; for (int i = 0; i < ncomponents; i++) { comp = target.getComponent(i); if (comp.isVisible()) { ps = comp.getPreferredSize(); if (verticalOrientation == Orientation.CENTER) top = (targetSize.height / 2) - (ps.height / 2); else if (verticalOrientation == Orientation.TOP) top = insets.top; else if (verticalOrientation == Orientation.BOTTOM) top = targetSize.height - ps.height - insets.bottom; comp.setBounds(left, top, ps.width, ps.height); left += ps.width + gap; } } }
private void layoutComponents( Container target, int xOffset, int yOffset, int maxwidth, int rowheight, SizeRequirements[] xChildren, SizeRequirements[] yChildren, int start, int end, boolean ltr) { SizeRequirements[] children = (SizeRequirements[]) ArrayUtils.subarray(xChildren, start, end); int[] xOffsets = new int[children.length]; int[] xSpans = new int[children.length]; SizeRequirements.calculateTiledPositions(maxwidth, null, children, xOffsets, xSpans, ltr); children = (SizeRequirements[]) ArrayUtils.subarray(yChildren, start, end); int[] yOffsets = new int[children.length]; int[] ySpans = new int[children.length]; SizeRequirements total = new SizeRequirements(rowheight, rowheight, rowheight, 0.5f); SizeRequirements.calculateAlignedPositions(rowheight, total, children, yOffsets, ySpans, ltr); Insets in = target.getInsets(); for (int i = 0; i < children.length; i++) { Component c = target.getComponent(i + start); c.setBounds( (int) Math.min((long) xOffset + (long) xOffsets[i], Integer.MAX_VALUE), (int) Math.min((long) yOffset + (long) yOffsets[i], Integer.MAX_VALUE), xSpans[i], ySpans[i]); } }
private static void drawSelection(JTree tree, Graphics g, final int width) { int y = 0; final int[] rows = tree.getSelectionRows(); final int height = tree.getRowHeight(); for (int row : rows) { final TreeCellRenderer renderer = tree.getCellRenderer(); final Object value = tree.getPathForRow(row).getLastPathComponent(); if (value == null) continue; final Component component = renderer.getTreeCellRendererComponent(tree, value, false, false, false, row, false); if (component.getFont() == null) { component.setFont(tree.getFont()); } g.translate(0, y); component.setBounds(0, 0, width, height); boolean wasOpaque = false; if (component instanceof JComponent) { final JComponent j = (JComponent) component; if (j.isOpaque()) wasOpaque = true; j.setOpaque(false); } component.paint(g); if (wasOpaque) { ((JComponent) component).setOpaque(true); } y += height; g.translate(0, -y); } }
/** * Lays out the container in the specified container. * * @param parent the component which needs to be laid out */ public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { Insets insets = parent.getInsets(); int ncomponents = parent.getComponentCount(); if (ncomponents == 0) { return; } // Total parent dimensions Dimension size = parent.getSize(); int totalW = size.width - (insets.left + insets.right); int totalH = size.height - (insets.top + insets.bottom); // Cell dimensions, including padding int totalCellW = totalW / gridSize.width; int totalCellH = totalH / gridSize.height; // Cell dimensions, without padding int cellW = (totalW - ((gridSize.width + 1) * hgap)) / gridSize.width; int cellH = (totalH - ((gridSize.height + 1) * vgap)) / gridSize.height; for (int i = 0; i < ncomponents; i++) { Component c = parent.getComponent(i); Rectangle rect = (Rectangle) compTable.get(c); if (rect != null) { int x = insets.left + (totalCellW * rect.x) + hgap; int y = insets.top + (totalCellH * rect.y) + vgap; int w = (cellW * rect.width) - hgap; int h = (cellH * rect.height) - vgap; c.setBounds(x, y, w, h); } } } }
public void layoutContainer(Container parent) { Dimension size = parent.getSize(); Insets insets = parent.getInsets(); int itop = insets.top; int ileft = insets.left; int ibottom = insets.bottom; int iright = insets.right; int rightWidth = right.getPreferredSize().width; int bottomHeight = bottom.getPreferredSize().height; int centerWidth = size.width - rightWidth - ileft - iright; int centerHeight = size.height - bottomHeight - itop - ibottom; center.setBounds(ileft, itop, centerWidth, centerHeight); right.setBounds(ileft + centerWidth, itop, rightWidth, centerHeight); // Lay out all status components, in order Enumeration status = leftOfScrollBar.elements(); while (status.hasMoreElements()) { Component comp = (Component) status.nextElement(); Dimension dim = comp.getPreferredSize(); comp.setBounds(ileft, itop + centerHeight, dim.width, bottomHeight); ileft += dim.width; } bottom.setBounds( ileft, itop + centerHeight, size.width - rightWidth - ileft - iright, bottomHeight); }
/** @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent) */ public void componentResized(ComponentEvent evt) { /* 获取目标组件 */ Component component = evt.getComponent(); /* 获取目标组件设置的边界和最小最大尺寸 */ Rectangle bounds = component.getBounds(); Dimension minSize = component.getMinimumSize(); Dimension maxSize = component.getMaximumSize(); /* 确定目标组件新的x轴坐标及宽度 */ if (bounds.width < minSize.width) { bounds.x -= (bounds.x == m_oldBounds.x ? 0 : minSize.width - bounds.width); bounds.width = minSize.width; } else if (bounds.width > maxSize.width) { bounds.x += (bounds.x == m_oldBounds.x ? 0 : bounds.width - maxSize.width); bounds.width = maxSize.width; } /* 确定目标组件新的y轴坐标及高度 */ if (bounds.height < minSize.height) { bounds.y -= (bounds.y == m_oldBounds.y ? 0 : minSize.height - bounds.height); bounds.height = minSize.height; } else if (bounds.height > maxSize.height) { bounds.y += (bounds.y == m_oldBounds.y ? 0 : bounds.height - maxSize.height); bounds.height = maxSize.height; } /* 设置目标组件的新边界 */ component.setBounds(bounds); /* 保存新的边界 */ m_oldBounds = bounds; }
@Override public void run(Component c) { final Rectangle r = c.getBounds(); r.width -= 64; r.height -= 64; c.setBounds(r); }
public boolean editCellAt(int index, EventObject e) { if (editor != null && !editor.stopCellEditing()) return false; if (index < 0 || index >= getModel().getSize()) return false; if (!isCellEditable(index)) return false; if (editorRemover == null) { KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); editorRemover = new CellEditorRemover(fm); fm.addPropertyChangeListener("permanentFocusOwner", editorRemover); // NOI18N } if (editor != null && editor.isCellEditable(e)) { editorComp = prepareEditor(index); if (editorComp == null) { removeEditor(); return false; } editorComp.setBounds(getCellBounds(index, index)); add(editorComp); editorComp.validate(); editingIndex = index; editor.addCellEditorListener(this); return true; } return false; }
private static void drawSelection(JTable table, int column, Graphics g, final int width) { int y = 0; final int[] rows = table.getSelectedRows(); final int height = table.getRowHeight(); for (int row : rows) { final TableCellRenderer renderer = table.getCellRenderer(row, column); final Component component = renderer.getTableCellRendererComponent( table, table.getValueAt(row, column), false, false, row, column); g.translate(0, y); component.setBounds(0, 0, width, height); boolean wasOpaque = false; if (component instanceof JComponent) { final JComponent j = (JComponent) component; if (j.isOpaque()) wasOpaque = true; j.setOpaque(false); } component.paint(g); if (wasOpaque) { ((JComponent) component).setOpaque(true); } y += height; g.translate(0, -y); } }
@Override public void doLayout() { for (Field field : usedFieldList) { Component component = field.getHandle().getDisplayer().getComponent(); int r = field.getRow(); int c = field.getColumn(); component.setBounds(x(c), y(r), w(c), h(r)); } }
private void doRohu(final Component cc, final Dimension dim, final int x, final int y) { if (cc != null) { final Dimension v = rozmer(dim, cc); final int x0 = x < 0 ? -v.width - x : x; final int y0 = y < 0 ? -v.height - y : y; cc.setBounds(x0, y0, v.width, v.height); // System.out.println(x0 + " " + y0 + v); } }
public void layoutContainer(Container parent) { final int componentCount = parent.getComponentCount(); final int width = parent.getWidth(); int y = 0; for (int i = 0; i < componentCount; i++) { final Component component = parent.getComponent(i); if (component.isVisible()) { final Dimension preferredCompSize = component.getPreferredSize(); if (component instanceof MainView) { component.setBounds(0, y, width, preferredCompSize.height); } else { int x = (int) (component.getAlignmentX() * (width - preferredCompSize.width)); component.setBounds(x, y, preferredCompSize.width, preferredCompSize.height); } y += preferredCompSize.height; } } }
public void layoutContainer(Container parent) { int divider = getDivider(parent); Insets insets = parent.getInsets(); int w = parent.getWidth() - insets.left - insets.right - divider; int x = insets.left; int y = insets.top; for (int k = 1; k < parent.getComponentCount(); k += 2) { Component comp1 = parent.getComponent(k - 1); Component comp2 = parent.getComponent(k); Dimension d = comp2.getPreferredSize(); comp1.setBounds(x, y, divider - m_hGap, d.height); comp2.setBounds(x + divider, y, w, d.height); y += d.height + m_vGap; } }
@Override public void layoutContainer(Container parent) { int width = parent.getWidth(); int height = parent.getHeight(); Component toolbar = parent.getComponent(0); Dimension toolbarSize = toolbar.isVisible() ? toolbar.getPreferredSize() : new Dimension(); toolbar.setBounds(0, 0, width, toolbarSize.height); parent.getComponent(1).setBounds(0, toolbarSize.height, width, height - toolbarSize.height); }
/** Paints the given JTable's table default header background at given x for the given width. */ private static void paintHeader(Graphics g, JTable table, int x, int width) { TableCellRenderer renderer = table.getTableHeader().getDefaultRenderer(); Component component = renderer.getTableCellRendererComponent(table, "", false, false, -1, 2); component.setBounds(0, 0, width, table.getTableHeader().getHeight()); ((JComponent) component).setOpaque(false); CELL_RENDER_PANE.paintComponent( g, component, null, x, 0, width, table.getTableHeader().getHeight(), true); }
public void doLayout() { super.doLayout(); if (getScrollbarDisplayPolicy() == SCROLLBARS_NEVER) { // Use this class's calculateChildSize() and re-do layout of child Component c = getComponent(0); Dimension cs = calculateChildSize(); Insets i = getInsets(); c.setBounds(i.left, i.top, cs.width, cs.height); } }
@Override public void doLayout() { int x = 0; for (int i = 0; i < getComponentCount(); i++) { final Component each = getComponent(i); final Dimension eachSize = each.getPreferredSize(); each.setBounds(x, 0, eachSize.width, getHeight()); x += each.getBounds().width; } }
protected void paintEditor(Graphics g) { Component component = grid.getEditorComponent(); if (component == null) { return; } Rectangle cellBounds = grid.getCellBounds(grid.getEditingRow(), grid.getEditingColumn()); component.setBounds(cellBounds); component.validate(); component.requestFocus(); }
public void measureLayout(Container target, Dimension dimension, int type) { int count = target.getComponentCount(); if (count > 0) { Insets insets = target.getInsets(); Dimension size = target.getSize(); int x = 0; int y = 0; int maxWidth = 0; int maxHeight = 0; double radius = Math.min( size.width - insets.left - insets.right, size.height - insets.top - insets.bottom) / 2; Dimension[] sizes = new Dimension[count]; for (int i = 0; i < count; i++) { Component c = target.getComponent(i); if (includeComponent(c)) { Dimension d = getComponentSize(c, type); int w = d.width; int h = d.height; sizes[i] = d; maxWidth = Math.max(maxWidth, w); maxHeight = Math.max(maxHeight, h); } } if (dimension != null) { dimension.width = (int) (2 * radius - maxWidth); dimension.height = (int) (2 * radius - maxHeight); } else { int mx = (size.width - insets.left - insets.right - 2 * hMargin) / 2; int my = (size.height - insets.top - insets.bottom - 2 * vMargin) / 2; x = 0; y = 0; radius -= Math.max(maxWidth, maxHeight) / 2; for (int i = 0; i < count; i++) { Component c = target.getComponent(i); if (includeComponent(c)) { Dimension d = sizes[i]; int w = d.width; int h = d.height; double angle = 2 * Math.PI * i / count; x = mx + (int) (Math.sin(angle) * radius); y = my - (int) (Math.cos(angle) * radius); c.setBounds(insets.left + hMargin + x - w / 2, insets.top + vMargin + y - h / 2, w, h); } } } } }
public static void setRelativeBounds( @NotNull Component parent, @NotNull Rectangle bounds, @NotNull Component child, @NotNull Container validationParent) { validationParent.add(parent); parent.setBounds(bounds); parent.validate(); child.setLocation(SwingUtilities.convertPoint(child, 0, 0, parent)); validationParent.remove(parent); }
public void layoutContainer(Container parent) { Insets insets = parent.getInsets(); if (parent.getComponentOrientation().isLeftToRight()) { int x = insets.left; for (Component component : parent.getComponents()) { Dimension ps = component.getPreferredSize(); component.setBounds( x, insets.top, ps.width, parent.getHeight() - insets.top - insets.bottom); x += ps.width - overlap; } } else { int x = parent.getWidth() - insets.right; for (Component component : parent.getComponents()) { Dimension ps = component.getPreferredSize(); component.setBounds( x - ps.width, insets.top, ps.width, parent.getHeight() - insets.top - insets.bottom); x += overlap - ps.width; } } }
public void layoutContainer(Container target) { // System.out.println("Laying out container " + target); super.layoutContainer(target); if (free != null) { // what is free?? Point loc = free.getLocation(); Dimension sz = free.getSize(); // System.out.println("Laying out free component " + free); free.setBounds(loc.x, loc.y, sz.width, sz.height); } }
public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { Insets margin = parent.getInsets(); int x = margin.left; int y = margin.top; int w = parent.getWidth() - (margin.left + margin.right); int h = parent.getHeight() - (margin.top + margin.bottom); Component header = findHeader(parent.getComponents()); if (header != null && header.isVisible()) { Dimension dim = header.getPreferredSize(); header.setBounds(x, y, w, dim.height); y += dim.height; h -= dim.height; } Component body = findBody(parent.getComponents()); if (body != null && body.isVisible()) { body.setBounds(x, y, w, h); } } }
private void rescaling() // method used to rescale UI { scalingfactor = Start.interfaceScalingFactor; // System.out.println("getPreferredSize().width=" + getPreferredSize().width); // System.out.println("getPreferredSize().height=" + getPreferredSize().height); int width = (int) (getPreferredSize().width * scalingfactor); int height = (int) (getPreferredSize().height * scalingfactor); // System.out.println("MainFrame scalingfactor=" + scalingfactor + " width=" + width + " // height=" + height); setPreferredSize( new Dimension( (int) (getPreferredSize().width * scalingfactor), (int) (getPreferredSize().height * scalingfactor))); setBounds(0, 0, (int) (1680 * scalingfactor), (int) (1050 * scalingfactor)); for (Component comp : this.getComponents()) { comp.setPreferredSize( new Dimension( (int) (comp.getPreferredSize().width * scalingfactor), (int) (comp.getPreferredSize().height * scalingfactor))); comp.setBounds( (int) (comp.getX() * scalingfactor), (int) (comp.getY() * scalingfactor), (int) (comp.getWidth() * scalingfactor), (int) (comp.getHeight() * scalingfactor)); // comp=rescaleComponent(comp); rescaleComponent(comp); if (comp instanceof JMenuBar) { JMenuBar jM = (JMenuBar) comp; for (Component lComp : jM.getComponents()) { rescaleComponent(lComp); } } if (comp instanceof JPanel) { JPanel jP = (JPanel) comp; for (Component lComp : jP.getComponents()) { rescaleComponent(lComp); } } if (comp instanceof JScrollPane) { JScrollPane jSp = (JScrollPane) comp; for (Component lComp : jSp.getComponents()) { rescaleComponent(lComp); } } } repaint(); revalidate(); }
/** * Lays out the container argument using this border layout. * * <p>This method actually reshapes the components in the specified container in order to satisfy * the constraints of this <code>BorderLayout</code> object. The <code>NORTH</code> and <code> * SOUTH</code> components, if any, are placed at the top and bottom of the container, * respectively. The <code>WEST</code> and <code>EAST</code> components are then placed on the * left and right, respectively. Finally, the <code>CENTER</code> object is placed in any * remaining space in the middle. * * <p>Most applications do not call this method directly. This method is called when a container * calls its <code>doLayout</code> method. * * @param target the container in which to do the layout. * @see java.awt.Container * @see java.awt.Container#doLayout() */ public void layoutContainer(Container target) { synchronized (target.getTreeLock()) { Insets insets = target.getInsets(); int top = insets.top; int bottom = target.getHeight() - insets.bottom; int left = insets.left; int right = target.getWidth() - insets.right; boolean ltr = target.getComponentOrientation().isLeftToRight(); Component c = null; if ((c = getChild(NORTH, ltr)) != null) { c.setSize(right - left, c.getHeight()); Dimension d = c.getPreferredSize(); c.setBounds(left, top, right - left, d.height); top += d.height + vgap; } if ((c = getChild(SOUTH, ltr)) != null) { c.setSize(right - left, c.getHeight()); Dimension d = c.getPreferredSize(); c.setBounds(left, bottom - d.height, right - left, d.height); bottom -= d.height + vgap; } if ((c = getChild(EAST, ltr)) != null) { c.setSize(c.getWidth(), bottom - top); Dimension d = c.getPreferredSize(); c.setBounds(right - d.width, top, d.width, bottom - top); right -= d.width + hgap; } if ((c = getChild(WEST, ltr)) != null) { c.setSize(c.getWidth(), bottom - top); Dimension d = c.getPreferredSize(); c.setBounds(left, top, d.width, bottom - top); left += d.width + hgap; } if ((c = getChild(CENTER, ltr)) != null) { c.setBounds(left, top, right - left, bottom - top); } } }