public void init(){
c=getContentPane();

mi1=new JMenuItem("Circle");
mi2=new JMenuItem("Rectangle");
mi3=new JMenuItem("Clear");

mi1.addActionListener(this);
mi2.addActionListener(this);
mi3.addActionListener(this);

m=new JMenu("Draw");
m.add(mi1);
m.add(mi2);
m.addSeparator();
m.add(mi3);

mb.add(m);

setJMenuBar(mb);
setBackground(Color.gray);
show();
}

public void actionPerformed(ActionEvent e){
Graphics g=c.getGraphics();

if(e.getSource()==mi1)
g.fillOval(40,40,100,100);

else if(e.getSource()==mi2)
g.fillRect(40,40,100,100);

else
c.repaint();
}
}
//<applet code="MenuTest.class" width=100 height=100></applet>