/*
 * @(#)PackerLayoutExampleFill.java    1.0 12/19/95 Rinaldo Di Giorgio
 *
 * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. Please refer to the file "copyright.html"
 * for further important copyright and licensing information.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */
import java.applet.*;
import java.awt.*;
import awt.*;
/**
  *     Demonstrate use of Packer Layout
  *     @author Rinaldo Di Giorgio
  */
public class PackerLayoutExampleFill extends Applet {
	public void init() {
		Button b;
		PackerLayout L = new PackerLayout();
		setLayout(L);
		PackerInfo I = new PackerInfo();
		String p = getParameter("FILL");
		if ( p == null ) 
			I.fillx = I.filly = false;
		else	
			I.fillx = I.filly = true;
		p = getParameter("NEGX");
		if ( p != null )
			I.fillx = !I.fillx; 
		p = getParameter("NEGY");
		if ( p != null )
			I.filly = !I.filly; 
		p = getParameter("PAD");
		if ( p == null ) 
			I.padx = I.pady = 0;
		else
			I.padx = I.pady = 20;

		I.widget = b = new Button("A");
		I.side = PackerInfo.TOP;
                System.out.println("About to add a button");
                list();
                add(b);
                list();
                System.out.println("Button added and adding layoutinfo");
                L.addLayoutInfo(I);
		I.widget = b = new Button("LONG NAME");
		I.side = PackerInfo.TOP;
                System.out.println("About to add a button");
                list();
                add(b);
                list();
                System.out.println("Button added and adding layoutinfo");
                L.addLayoutInfo(I);
                System.out.println("Layout Info ended about to call preferredSize");
		resize(preferredSize());
                System.out.println("Return from resize to the preffered size");
                list();
        }

	public boolean action(Event e, Object arg) {
		return true;
	}
        public void paint( Graphics g) {
                g.setColor(Color.lightGray);
                g.fill3DRect(0,0,size().width,size().height,true);
        }

}

