/home/wpollock1/public_html/Java/OverlapHeavy.java

// This class shows what happens when you have two heavyweight
// components that overlap.  (The one added last ends up on
// the bottom, not the top as you might expect.)
//
// Written 11/2009 by Wayne Pollock, Tampa Florida USA

import java.awt.*;
import java.awt.event.*;

public class OverlapHeavy extends Frame
{
   public static void main ( String [] args )
   {
      Frame frame = new OverlapHeavy();
      frame.setVisible( true );
      frame.requestFocus();
   }

   public OverlapHeavy ()
   {
      // Set Frame properties:
      setLayout( null );  // Don't use any layout manager.
      setTitle( "Overlapping heavyweight components");
      setSize( 470, 220 );

      // Create Components and adjust their properties:

      Button b1 = new Button("Added First");
      Button b2 = new Button("Added Second");

      b1.setBackground( Color.GREEN );
      b1.setBounds( 40, 50, 100, 70 );  // x, y, width, height

      b2.setBackground( Color.CYAN );
      b2.setBounds( 100, 85, 100, 70 );

      // Add components and hook up event handling:
      add( b1 );
      add( b2 );

      addWindowListener( new WindowAdapter()
         {   public void windowClosing ( WindowEvent we )
             {   System.exit( 0 );
             }
         }
      );
   }
}