import java.awt.*; // needed for the graphics class FigureCanvas extends Canvas { private int height; private int width; private Figure [] figures = new Figure [10]; private int fignum = 0; public FigureCanvas (int h, int w) { height = h; width = w; setBackground(Color.white); } public void add(Figure fig) { if (fignum >= figures.length) { Figure [] newfigs = new Figure [figures.length+10]; for (int i = 0; i < figures.length; i++) { newfigs[i] = figures[i]; } figures = newfigs; } figures[fignum] = fig; fignum++; } public void paint(Graphics g) { for (int i = 0; i < fignum; i++) { figures[i].draw(g); } } public void updatePosition(int row, int col) { System.out.println("before getting graphics"); Graphics g = getGraphics(); g.setColor (Color.white); g.fillRect(row,col,20,30); } }