      // General Information
      // ------------------------------------------------------------

      // File:  Piano.java
      // Type:  java applet
      // Date:  Sun Jan  5, 1997
      // Name:  blue
      // Line:  (Piano V4)


      // Applet Description
      // ------------------------------------------------------------

      /*
          
         The new feature is that the keys are inset within the
         keyboard.

      */

      // Package Identification
      // ------------------------------------------------------------

         package development.piano.v4;

      // Required packages
      // ------------------------------------------------------------

         import java.awt.*;
         import java.applet.*;
         import blue.painter.*;
         import blue.shapes.*;


      // Applet class
      // ------------------------------------------------------------

         public class Piano extends java.applet.Applet
         {

            private int whiteKeyHeight = 80;
            private int whiteKeyWidth = 20;
            private int nrOfWhiteKeys = 8;

            private Keyboard keyboard = null;
            private KeyboardBuffer keyboardBuffer = null;

         // overriding init of java.awt.applet
            public void init() 
            {
            // Establish a layout so that the included
            // component with be centered within the applet.
               this.setLayout(new GridLayout(1,1));

            // Add a key
               keyboard = new Keyboard(nrOfWhiteKeys,whiteKeyHeight,whiteKeyWidth);
               keyboardBuffer = new KeyboardBuffer(keyboard);
               add(keyboardBuffer);
            }

         }


         class Key extends Painter
         {
            int width;
            int height;
            blue.shapes.Rectangle border;

            Key(int height, int width)
            {
               super(width,height);
               this.width = width;
               this.height = height;
               border = new blue.shapes.Rectangle(height-1,width-1);
               draw();
            }

            public void draw()
            {
               draw(border);
            }
               

         }

         class Keyboard extends SupportingPainter
         {
            int size;
            double width;
            double height;
            blue.shapes.Rectangle frame;

            Key keys[];

            Keyboard(int s, int h, int w)
            {
               super(s+20,w*s+20);
               setLayout(new GridLayout(1,s));

               frame = new blue.shapes.Rectangle(h+10,s*w+10);

               size = s;
               width = w;
               height = h;

               keys = new Key[s+1];

               for ( int n = 1; n <= s; n++ )
               {
                  keys[n] = new Key(h,w);
               };

               for ( int i = 1; i <= s; i++ )
               {
                  add( keys[i] );
               };

               draw();
               repaint();
            }

            public void draw()
            {

               for ( int n = 1; n <= size; n++ )
               {
                 keys[n].draw();
               };
            }
              
            public Insets insets()
            {
              return new Insets(15,15,15,15);
            }

         }

         class KeyboardBuffer extends Panel
         {
            KeyboardBuffer(Keyboard k)
            {
               setLayout(new GridBagLayout());
               add(k);
            }
         }

