⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridbaglayout.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * @param       comp the component to be queried     * @return      the contraints for the specified component.     * @since       JDK1.0     */    protected GridBagConstraints lookupConstraints(Component comp) {        GridBagConstraints constraints = (GridBagConstraints) comptable.get(comp);        if (constraints == null) {            setConstraints(comp, defaultConstraints);            constraints = (GridBagConstraints) comptable.get(comp);        }        return constraints;    }    /**     * Determines the origin of the layout grid.     * Most applications do not call this method directly.     * @return     the origin of the cell in the top-left     *                    corner of the layout grid.     * @since      JDK1.1     */    public Point getLayoutOrigin() {        Point origin = new Point(0, 0);        if (layoutInfo != null) {            origin.x = layoutInfo.startx;            origin.y = layoutInfo.starty;        }        return origin;    }    /**     * Determines column widths and row heights for the layout grid.     * <p>     * Most applications do not call this method directly.     * @return     an array of two arrays, containing the widths     *                       of the layout columns and     *                       the heights of the layout rows.     * @since      JDK1.1     */    public int[][] getLayoutDimensions() {        if (layoutInfo == null)            return new int[2][0];        int dim[][] = new int[2][];        dim[0] = new int[layoutInfo.width];        dim[1] = new int[layoutInfo.height];        System.arraycopy(layoutInfo.minWidth, 0, dim[0], 0, layoutInfo.width);        System.arraycopy(layoutInfo.minHeight, 0, dim[1], 0, layoutInfo.height);        return dim;    }    /**     * Determines the weights of the layout grid's columns and rows.     * Weights are used to calculate how much a given column or row     * stretches beyond its preferred size, if the layout has extra     * room to fill.     * <p>     * Most applications do not call this method directly.     * @return      an array of two arrays, representing the     *                    horizontal weights of the layout columns     *                    and the vertical weights of the layout rows.     * @since       JDK1.1     */    public double[][] getLayoutWeights() {        if (layoutInfo == null)            return new double[2][0];        double weights[][] = new double[2][];        weights[0] = new double[layoutInfo.width];        weights[1] = new double[layoutInfo.height];        System.arraycopy(layoutInfo.weightX, 0, weights[0], 0, layoutInfo.width);        System.arraycopy(layoutInfo.weightY, 0, weights[1], 0, layoutInfo.height);        return weights;    }    /**     * Determines which cell in the layout grid contains the point     * specified by <code>(x,&nbsp;y)</code>. Each cell is identified     * by its column index (ranging from 0 to the number of columns     * minus 1) and its row index (ranging from 0 to the number of     * rows minus 1).     * <p>     * If the <code>(x,&nbsp;y)</code> point lies     * outside the grid, the following rules are used.     * The column index is returned as zero if <code>x</code> lies to the     * left of the layout, and as the number of columns if <code>x</code> lies     * to the right of the layout. The row index is returned as zero     * if <code>y</code> lies above the layout,     * and as the number of rows if <code>y</code> lies     * below the layout.     * @param      x    the <i>x</i> coordinate of a point.     * @param      y    the <i>y</i> coordinate of a point.     * @return     an ordered pair of indexes that indicate which cell     *             in the layout grid contains the point     *             (<i>x</i>,&nbsp;<i>y</i>).     * @since      JDK1.1     */    public Point location(int x, int y) {        Point loc = new Point(0, 0);        int i, d;        if (layoutInfo == null)            return loc;        d = layoutInfo.startx;        for (i = 0; i < layoutInfo.width; i++) {            d += layoutInfo.minWidth[i];            if (d > x)                break;        }        loc.x = i;        d = layoutInfo.starty;        for (i = 0; i < layoutInfo.height; i++) {            d += layoutInfo.minHeight[i];            if (d > y)                break;        }        loc.y = i;        return loc;    }    /**     * Adds the specified component with the specified name to the layout.     * @param      name         the name of the component.     * @param      comp         the component to be added.     * @since      JDK1.0     */    public void addLayoutComponent(String name, Component comp) {}    /**     * Adds the specified component to the layout, using the specified     * constraint object.     * @param      comp         the component to be added.     * @param      constraints  an object that determines how     *                              the component is added to the layout.     * @since      JDK1.0     */    public void addLayoutComponent(Component comp, Object constraints) {        if (constraints instanceof GridBagConstraints) {            setConstraints(comp, (GridBagConstraints) constraints);        }else if (constraints instanceof String) {//Netscape : Just Ignore it        }else if (constraints != null) {            throw new IllegalArgumentException("cannot add to layout: constraint must be a GridBagConstraint");        }    }    /**     * Removes the specified component from this layout.     * <p>     * Most applications do not call this method directly.     * @param    comp   the component to be removed.     * @see      java.awt.Container#remove(java.awt.Component)     * @see      java.awt.Container#removeAll()     * @since    JDK1.0     */    public void removeLayoutComponent(Component comp) {}    /**     * Determines the preferred size of the <code>target</code>     * container using this grid bag layout.     * <p>     * Most applications do not call this method directly.     * @param     target   the container in which to do the layout.     * @see       java.awt.Container#getPreferredSize     * @since     JDK1.0     */    public Dimension preferredLayoutSize(Container parent) {        GridBagLayoutInfo info = GetLayoutInfo(parent, PREFERREDSIZE);        return GetMinSize(parent, info);    }    /**     * Determines the minimum size of the <code>target</code> container     * using this grid bag layout.     * <p>     * Most applications do not call this method directly.     * @param     target   the container in which to do the layout.     * @see       java.awt.Container#doLayout     * @since     JDK1.0     */    public Dimension minimumLayoutSize(Container parent) {        GridBagLayoutInfo info = GetLayoutInfo(parent, MINSIZE);        return GetMinSize(parent, info);    }    /**     * Returns the maximum dimensions for this layout given the components     * in the specified target container.     * @param target the component which needs to be laid out     * @see Container     * @see #minimumLayoutSize     * @see #preferredLayoutSize     */    public Dimension maximumLayoutSize(Container target) {        return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);    }    /**     * Returns the alignment along the x axis.  This specifies how     * the component would like to be aligned relative to other     * components.  The value should be a number between 0 and 1     * where 0 represents alignment along the origin, 1 is aligned     * the furthest away from the origin, 0.5 is centered, etc.     */    public float getLayoutAlignmentX(Container parent) {        return 0.5f;    }    /**     * Returns the alignment along the y axis.  This specifies how     * the component would like to be aligned relative to other     * components.  The value should be a number between 0 and 1     * where 0 represents alignment along the origin, 1 is aligned     * the furthest away from the origin, 0.5 is centered, etc.     */    public float getLayoutAlignmentY(Container parent) {        return 0.5f;    }    /**     * Invalidates the layout, indicating that if the layout manager     * has cached information it should be discarded.     */    public void invalidateLayout(Container target) {}				          /**     * Lays out the specified container using this grid bag layout.     * This method reshapes components in the specified container in     * order to satisfy the contraints of this <code>GridBagLayout</code>     * object.     * <p>     * Most applications do not call this method directly.     * @param parent the container in which to do the layout.     * @see java.awt.Container     * @see java.awt.Container#doLayout     * @since JDK1.0     */    public void layoutContainer(Container parent) {        ArrangeGrid(parent);    }    /**     * Returns a string representation of this grid bag layout's values.     * @return     a string representation of this grid bag layout.     * @since      JDK1.0     */    public String toString() {        return getClass().getName();    }    /**     * Print the layout information.  Useful for debugging.     */    /* DEBUG     *     *  protected void DumpLayoutInfo(GridBagLayoutInfo s) {     *    int x;     *     *    System.out.println("Col\tWidth\tWeight");     *    for (x=0; x<s.width; x++) {     *      System.out.println(x + "\t" +     *			 s.minWidth[x] + "\t" +     *			 s.weightX[x]);     *    }     *    System.out.println("Row\tHeight\tWeight");     *    for (x=0; x<s.height; x++) {     *      System.out.println(x + "\t" +     *			 s.minHeight[x] + "\t" +     *			 s.weightY[x]);     *    }     *  }     */    /**     * Print the layout constraints.  Useful for debugging.     */    /* DEBUG     *     *  protected void DumpConstraints(GridBagConstraints constraints) {     *    System.out.println(     *		       "wt " +     *		       constraints.weightx +     *		       " " +     *		       constraints.weighty +     *		       ", " +     *     *		       "box " +     *		       constraints.gridx +     *		       " " +     *		       constraints.gridy +     *		       " " +     *		       constraints.gridwidth +     *		       " " +     *		       constraints.gridheight +     *		       ", " +     *     *		       "min " +     *		       constraints.minWidth +     *		       " " +     *		       constraints.minHeight +     *		       ", " +     *     *		       "pad " +     *		       constraints.insets.bottom +     *		       " " +     *		       constraints.insets.left +     *		       " " +     *		       constraints.insets.right +     *		       " " +     *		       constraints.insets.top +

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -