/** * paint method in your own class that extends Canvas * * @param g where to paint e.g. printer, screen, RAM */ public void paint( Graphics g ) { // don't call super.paint(). update() has already cleared the screen. // You might want to override update to just call paint() if that clearing is not needed. // display word "today" centred at x,y FontMetrics fm = getFontMetrics( g.getFont() ); String wording = "today"; int xadj = fm.stringWidth( wording ) / 2; // position bottom left corner of the text g.drawString( wording, x-xadj, y ); // draw a red line from x1,y1 to x2,y2 g.setColor( Color.red ); g.drawLine( x1, y1, x2, y2); // draw an pre-existing Image.imX, imY is top left corner of the Image. g.drawImage ( image, imX, imY, imWidth, imHeight, this); } // end paint