You'll need to keep track of what figures have been created so far, and you can do that in an array. You'll also need to be able to determine when a keyclick occurs inside a figure so you know which figure has been selected.
int nFigures; // the current number of figures Figure fig[]; // the array of figuresHere, figure is an abstract class, see Figure.java. Particular kinds of figures subclass it, for instance, RectFigure is described in RectFigure.java.
Editor.java, extends Applet.
Figure.java, abstract class.
LineFigure.java, extends Figure.
OvalFigure.java, extends Figure.
RectFigure.java, extends Figure.