001    /*
002     * This file is part of the Echo Point Project.  This project is a
003     * collection of Components that have extended the Echo Web Application
004     * Framework Version 3.
005     *
006     * Version: MPL 1.1
007     *
008     * The contents of this file are subject to the Mozilla Public License Version
009     * 1.1 (the "License"); you may not use this file except in compliance with
010     * the License. You may obtain a copy of the License at
011     * http://www.mozilla.org/MPL/
012     *
013     * Software distributed under the License is distributed on an "AS IS" basis,
014     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015     * for the specific language governing rights and limitations under the
016     * License.
017     */
018    
019    package echopoint;
020    
021    import echopoint.internal.AbstractContainer;
022    import nextapp.echo.app.Extent;
023    import nextapp.echo.app.Component;
024    
025    /**
026     * <b>Strut</b> is a very simple component that can have a fixed width and height. It
027     * is most commonly used to create precise spaces between components laid out
028     * in a container component such as {@link nextapp.echo.app.Column}.
029     *
030     * <p>The following shows how to add a 50 px space between two labels in
031     * a {@link nextapp.echo.app.Row} container.</p>
032     * <pre>
033     *   import echopoint.Strut;
034     *   import nextapp.echo.app.Label;
035     *   import nextapp.echo.app.Row;
036     *
037     *     ...
038     *     final Row row = new Row();
039     *     row.add( new Label( "Label 1" ) );
040     *     row.add( new Strut( 50, 10 ) );
041     *     row.add( new Label( "Label 2" ) );
042     * </pre>
043     *
044     * @author Brad Baker <p>Modified by Rakesh 2008-07-20</p>
045     * @version $Id: Strut.java 42 2008-07-21 12:42:21Z sptrakesh $
046     */
047    public class Strut extends AbstractContainer
048    {
049      private static final long serialVersionUID = 1l;
050    
051      /** Constructs a <b>Strut</b> that is 10px wide by 10px high. */
052      public Strut()
053      {
054        this( null, null );
055      }
056    
057      /**
058       * Constructs a <b>Strut</b> that is <code>width</code> pixels wide by
059       * <code>height</code> pixels high.
060       *
061       * @param width The width in pixels for this component.
062       * @param height The height in pixels for this component.
063       */
064      public Strut( final int width, final int height )
065      {
066        this( new Extent( width ), new Extent( height ) );
067      }
068    
069      /**
070       * Constructs a <b>Strut</b>.  This is the designated constructor.
071       *
072       * @param width The width of the Strut
073       * @param height The height of the Strut
074       */
075      public Strut( final Extent width, final Extent height )
076      {
077        setWidth( width );
078        setHeight( height );
079      }
080    
081      /**
082       * <b>Strut</b> is <i>NOT</i> allowed to have any children.
083       *
084       * @see nextapp.echo.app.Component#isValidChild(nextapp.echo.app.Component)
085       */
086      @Override
087      public boolean isValidChild( final Component child )
088      {
089        return false;
090      }
091    }