/*
    This class extends the JFrame class. This class defines
    a kind of JFrame that has a MyCoolJButton and a MyFakeButton
    in it.

    Try this class with both the BorderLayout and the FlowLayout.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;

public class JFrameWithMyCoolJButtonAndMyFakeButton extends JFrame
{
   // here are references to the two "buttons"
   private MyCoolJButton myButton;
   private MyFakeButton  fakeButton;

   // constructor
   JFrameWithMyCoolJButtonAndMyFakeButton(String title)
   {
      // call super class constructor
      super(title);

      // change the layout manager of this frame (notice that
      // the new layout manager is an anonymous object)
      getContentPane().setLayout( new FlowLayout() );

      // create a MyCoolJButton object
      myButton = new MyCoolJButton("Off");
      // add the button to this frame
      getContentPane().add( myButton );

      // create a MyCoolJPanel object
      fakeButton = new MyFakeButton("OFF");
      // add the panel to this frame
      getContentPane().add( fakeButton );

      // listen for the close window event
      // (this uses an anonymous, inner, adapter class)
      addWindowListener( new WindowAdapter()
        {public void windowClosing(WindowEvent e){System.exit(0);}});

   }//constructor

   // a get method for the button
   public MyCoolJButton getButton()
   {
      return myButton;
   }

   // a get method for the panel
   public MyFakeButton getPanel()
   {
      return fakeButton;
   }

   public static void main(String[] args)
   {
      // create a frame object
      JFrameWithMyCoolJButtonAndMyFakeButton frame
          = new JFrameWithMyCoolJButtonAndMyFakeButton("Frame With MyCoolJButton and MyFakeButton");

      // set the size of the frame
      frame.setSize(200, 100);
      // move the frame away from its default location
      frame.setLocation(100, 100);
      // make the frame appear
      frame.setVisible(true);
   }//main

}//JFrameWithMyCoolJButtonAndMyCoolJPanel2
