import java.awt.*; import java.net.*; /** * A canvas that contains a background picture which is stretched to fill the entire canvas. * @author Torbjörn Nilsson * @version 1.0 */ public class Icon extends Canvas { Image bkg; ClientThread cliTh; int newState; /** * Use this contructor. * pic - referens to picture to Iconize * ct - the CLientThread object whose state will be updated * state - the new state that will be set in the given ct */ Icon(Image pic, ClientThread ct, int state) { bkg = pic; cliTh = ct; newState = state; resize(100,100); } /** * Generate a callback to the ClientThread given in contructor, and set a new screen in it. */ public boolean mouseDown(Event e, int x, int y) { cliTh.setNewScreen(newState); // System.out.println("Icon: "+this+" "+newState); return true; } /** * No flickering. */ public void update(Graphics g) { // override paint(g); } /** * Draw the icon pic. */ public void paint(Graphics g) { // System.out.println("canvas:"+g); Dimension d = size(); if (bkg != null) g.drawImage(bkg,0,0,d.width, d.height, this ); } }