示例#1
0
  /**
   * Constructs a <code>BoxLayout</code> object.
   *
   * @param container The container that needs to be laid out.
   * @param way The orientation of the components.
   * @exception AWTError If way has an invalid value.
   */
  public BoxLayout(Container container, int way) {
    int width = 0;
    int height = 0;
    ComponentOrientation orientation = container.getComponentOrientation();

    this.container = container;
    this.way = way;

    switch (way) {
      case X_AXIS:
        width = 1;
        break;
      case Y_AXIS:
        height = 1;
        break;
      case LINE_AXIS:
        if (orientation.isHorizontal()) height = 1;
        else width = 1;
        break;
      case PAGE_AXIS:
        if (!orientation.isHorizontal()) height = 1;
        else width = 1;
        break;
      default:
        throw new AWTError("Invalid value for way");
    }

    grid = new GridLayout(width, height);
  }
示例#2
0
 /**
  * Resolve the axis type of a component, given a layout orientation
  *
  * @param c a Swing Component, should be either a Box or a Container using a BoxLayout.
  * @param layout the layout orientation of the component. One of {@link
  *     javax.swing.BoxLayout#X_AXIS}, {@link javax.swing.BoxLayout#Y_AXIS}, {@link
  *     javax.swing.BoxLayout#LINE_AXIS}, or {@link javax.swing.BoxLayout#PAGE_AXIS}.
  * @return one of {@link javax.swing.BoxLayout#X_AXIS}, or {@link javax.swing.BoxLayout#Y_AXIS},
  */
 public static int getAxis(JComponent c, int layout) {
   ComponentOrientation o = c.getComponentOrientation();
   switch (layout) {
     case BoxLayout.LINE_AXIS:
       return o.isHorizontal() ? BoxLayout.X_AXIS : BoxLayout.Y_AXIS;
     case BoxLayout.PAGE_AXIS:
       return o.isHorizontal() ? BoxLayout.Y_AXIS : BoxLayout.X_AXIS;
     default:
       return layout;
   }
 }
示例#3
0
  /**
   * Constructs an instance of <code>AbstractFormBuilder</code> for the given FormLayout and layout
   * container.
   *
   * @param layout the {@link FormLayout} to use
   * @param container the layout container
   * @throws NullPointerException if the layout or container is null
   */
  public AbstractFormBuilder(FormLayout layout, Container container) {
    if (layout == null) throw new NullPointerException("The layout must not be null.");

    if (container == null) throw new NullPointerException("The layout container must not be null.");

    this.container = container;
    this.layout = layout;

    container.setLayout(layout);
    currentCellConstraints = new CellConstraints();
    ComponentOrientation orientation = container.getComponentOrientation();
    leftToRight = orientation.isLeftToRight() || !orientation.isHorizontal();
  }
 void setComponentOrientation(ComponentOrientation orientation) {
   horizontal = orientation.isHorizontal();
   leftToRight = orientation.isLeftToRight();
 }