// This Class is (c)opyright 1999 by Geoff Knagge. It may be freely used // for any non-commercial purpose on the following conditions: // 1. You indemnify the copyright holder of all possible liability // resulting from its use. // 2. You provide a link back to the source of this file, that is // http://browse.to/gogogeoff // // Use of this class shows your agreement to the above. import java.awt.*; import java.awt.event.*; public class ColourPanel extends Panel implements MouseListener { // A ColourPanel is a horiztonal set of panels, which may include any // of a Panel with a label for the set, several coloured Panels, and // a results panel, which displays feedback on previous moves. // The mastermind applet uses an array of these to create the "history" // section of the game area. ///////////////////// instance data Color[] Colours = { Color.red, Color.green, Color.yellow, Color.blue, Color.white, Color.black, Color.magenta, Color.orange, Color.pink, Color.gray}; Panel[] panels; // the array of panels Label prompt; // the text to be displayed to left of the panel ResultsCanvas resultsPanel; // actually a panel in the applet... int[] numbers; // this stores a copy of the colours used for each // panel... used when scrolling the history list int numright; // number of pieces in the right spot int numwrong; // number of pieces of the right colour PNZColours thisGame; int id; // each has an id so that the main program knows // which panel was clicked. ///////////////////////////////////// Mouse Listener Methods // Any class which is defined with the words // "implements MouseListener" must include these methods public void mouseClicked(MouseEvent e) { // finds which panel was clicked and sends this info to the // parent program. int subPanel=0; for (int cnt=0; cnt