preferredHeightMeasure ); return new LayoutInfo(x, y);
preferredHeightMeasure ); return new LayoutInfo(x, y);
/** * Computes and returns the horizontal and vertical grid origins. Performs * the same layout process as <code>#layoutContainer</code> but does not * layout the components. * <p> * * This method has been added only to make it easier to debug the form * layout. <strong>You must not call this method directly; It may be removed * in a future release or the visibility may be reduced.</strong> * * @param parent * the <code>Container</code> to inspect * @return an object that comprises the grid x and y origins */ public LayoutInfo getLayoutInfo(Container parent) { synchronized (parent.getTreeLock()) { initializeColAndRowComponentLists(); Dimension size = parent.getSize(); Insets insets = parent.getInsets(); int totalWidth = size.width - insets.left - insets.right; int totalHeight = size.height - insets.top - insets.bottom; int[] x = computeGridOrigins(parent, totalWidth, insets.left, colSpecs, colComponents, colGroupIndices, minimumWidthMeasure, preferredWidthMeasure); int[] y = computeGridOrigins(parent, totalHeight, insets.top, rowSpecs, rowComponents, rowGroupIndices, minimumHeightMeasure, preferredHeightMeasure); return new LayoutInfo(x, y); } }
/** * Paints the form's grid lines and diagonals. * * @param g * the Graphics object used to paint */ private void paintGrid(Graphics g) { if (!(getLayout() instanceof FormLayout)) { return; } FormLayout.LayoutInfo layoutInfo = FormDebugUtils.getLayoutInfo(this); int left = layoutInfo.getX(); int top = layoutInfo.getY(); int width = layoutInfo.getWidth(); int height = layoutInfo.getHeight(); g.setColor(gridColor); // Paint the column bounds. for (int col = 0; col < layoutInfo.columnOrigins.length; col++) { g.fillRect(layoutInfo.columnOrigins[col], top, 1, height); } // Paint the row bounds. for (int row = 0; row < layoutInfo.rowOrigins.length; row++) { g.fillRect(left, layoutInfo.rowOrigins[row], width, 1); } if (paintDiagonals) { g.drawLine(left, top, left + width, top + height); g.drawLine(left, top + height, left + width, top); } }
/** * Paints the form's grid lines and diagonals. * * @param g the Graphics object used to paint */ private void paintGrid(Graphics g) { if (!(getLayout() instanceof FormLayout)) { return; } FormLayout.LayoutInfo layoutInfo = FormDebugUtils.getLayoutInfo(this); int left = layoutInfo.getX(); int top = layoutInfo.getY(); int width = layoutInfo.getWidth(); int height = layoutInfo.getHeight(); g.setColor(gridColor); // Paint the column bounds. for (int col = 0; col < layoutInfo.columnOrigins.length; col++) { g.fillRect(layoutInfo.columnOrigins[col], top, 1, height); } // Paint the row bounds. for (int row = 0; row < layoutInfo.rowOrigins.length; row++) { g.fillRect(left, layoutInfo.rowOrigins[row], width, 1); } if (paintDiagonals) { g.drawLine(left, top, left + width, top + height); g.drawLine(left, top + height, left + width, top); } }
/** * Return the total height of the form as calculated by the FormLayout * manager. * * @return the height of the form as determined by the FormLayout manager */ public int getFormHeight() { FormLayout.LayoutInfo linfo = getLayoutInfo(); return linfo.getHeight(); }
/** * Return the total width of the form as calculated by the FormLayout * manager. * * @return the width of the form as determined by the FormLayout manager */ public int getFormWidth() { FormLayout.LayoutInfo linfo = getLayoutInfo(); return linfo.getWidth(); }