gov.lanl.GUITools
Class GridBagHelper

java.lang.Object
  |
  +--gov.lanl.GUITools.GridBagHelper

public final class GridBagHelper
extends java.lang.Object

The class GridBagHelper contains methods for constraining the layout for the GridBagConstraints in GridBagLayout..

  • constrain for setting up the gridbag constraints

    To use any of the routine, just import gov.lanl.Utility.*; then call the method with GridBagHelper.methodname(parameters)

     

    Method Summary
    static int add1Component(java.awt.Container cont, java.awt.Component c1, int yrow, int top, int bot)
              Adds one component and returns the next row number
    static int add2Components(java.awt.Container cont, java.awt.Component c1, java.awt.Component c2, int yrow, int top, int bot)
              Adds two components side-by-side in the row and returns the next row number
    static int addComponentInRow(java.awt.Container cont, java.awt.Component c1, int xcol, int yrow, int top, int bot)
              Adds a component in the row and returns the next col number
    static int addLastComponent(java.awt.Container cont, java.awt.Component c1, int yrow, int top, int bot)
              Adds one component stretches ,grows, and returns the next row number
    static void constrain(java.awt.Container container, java.awt.Component component, int grid_x, int grid_y, int grid_width, int grid_height, int fill, int anchor, double weight_x, double weight_y, int top, int left, int bottom, int right)
              Adds component with constraints to the container
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Method Detail

    constrain

    public static final void constrain(java.awt.Container container,
                                       java.awt.Component component,
                                       int grid_x,
                                       int grid_y,
                                       int grid_width,
                                       int grid_height,
                                       int fill,
                                       int anchor,
                                       double weight_x,
                                       double weight_y,
                                       int top,
                                       int left,
                                       int bottom,
                                       int right)
    Adds component with constraints to the container

    Parameters:
    container - the container to which the component will be added
    component - the component/widget which will be added to the container
    grid_x - the x grid position of the component
    grid_y - the y grid position of the component
    grid_width - the width of the component in grid cells
    grid_height - the height of the component in grid cells
    fill - which dimensions of the component will grow
    anchor - specifies how the component will be displayed if smaller than cells
    weight_x - specifies how extra space in x will be distributed
    weight_y - specifies how extra space in y will be distributed
    top - the top margin
    left - the left margin
    bottom - the bottom margin
    right - the right margin
    See Also:
    GridBagConstraints

    add1Component

    public static final int add1Component(java.awt.Container cont,
                                          java.awt.Component c1,
                                          int yrow,
                                          int top,
                                          int bot)
    Adds one component and returns the next row number

    Parameters:
    cont - the container to add the component to
    c1 - the component to add
    yrow - the ygrid row in which to add the component; xgrid is 0
    Returns:
    next row number

    addLastComponent

    public static final int addLastComponent(java.awt.Container cont,
                                             java.awt.Component c1,
                                             int yrow,
                                             int top,
                                             int bot)
    Adds one component stretches ,grows, and returns the next row number

    Parameters:
    cont - the container to add the component to
    c1 - the component to add
    yrow - the ygrid row in which to add the component; xgrid is 0
    Returns:
    next row number

    add2Components

    public static final int add2Components(java.awt.Container cont,
                                           java.awt.Component c1,
                                           java.awt.Component c2,
                                           int yrow,
                                           int top,
                                           int bot)
    Adds two components side-by-side in the row and returns the next row number

    Parameters:
    cont - the container to add the components to
    c1 - left most component to add; at xgrid of 0
    c2 - right most component to add; at xgrid of 1
    yrow - the ygrid row in which to add the component
    Returns:
    next row number

    addComponentInRow

    public static final int addComponentInRow(java.awt.Container cont,
                                              java.awt.Component c1,
                                              int xcol,
                                              int yrow,
                                              int top,
                                              int bot)
    Adds a component in the row and returns the next col number

    Parameters:
    cont - the container to add the components to
    c1 - left most component to add; at xgrid of 0
    xcol - the xgrid col in which to add the component
    yrow - the ygrid row in which to add the component
    Returns:
    next col number