// General Information // ------------------------------------------------------------ // File: Piano.java // Type: java applet // Date: Sun Jan 5, 1997 // Name: blue // Line: (Piano V1) // Applet Description // ------------------------------------------------------------ /* This applet will simply display a key of given height and width in the middle of the applet area. The height and width are established globally. */ // Package Identification // ------------------------------------------------------------ package development.piano.v1; // 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; // 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 add(new Key(whiteKeyHeight,whiteKeyWidth)); } } 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); } }