FileDocCategorySizeDatePackage
PutGet.javaAPI DocExample1326Tue Nov 13 16:41:20 GMT 2001None

PutGet.java

// File: PutGet.java
// T Balls : Nov 2001
// Example solution to Ch5 Ex1

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * This class provides the screen "holder" for the three classes:
 * Putter, Store and Getter
 */
public class PutGet extends JFrame
{
   Store store = new Store();
   Putter putter = new Putter( store );
   Getter getter = new Getter( store );

   public PutGet()
   {
      JPanel topLine = new JPanel();
      topLine.setLayout( new GridLayout( 1, 3 ) );
      topLine.add( new JLabel( "Putter object", JLabel.CENTER ) );
      topLine.add( new JLabel( "The Store", JLabel.CENTER ) );
      topLine.add( new JLabel( "Getter object", JLabel.CENTER ) );
      getContentPane().add( topLine, BorderLayout.NORTH );

      JPanel displayPanel = new JPanel();
      displayPanel.setLayout( new GridLayout( 1, 3 ) );
      displayPanel.add( putter );
      displayPanel.add( store );
      displayPanel.add( getter );

      getContentPane().add( displayPanel, BorderLayout.CENTER );

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

      pack();
      setVisible( true );
   }

   public static void main( String[] commandLineArguments )
   {
      new PutGet();
   }
}