My code is that am able to draw different diagrams on mouse drag to the panel but i cant see the diagram drawn if i draw another diagram . i.e i want all the diagrams to be displayed .
if i had drawn rectangle and now if i press the button ellipse to draw a ellipse then the rectangle is vanishing ,but i want all to be remained on the screen.please help me with this

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.Graphics;

class drawing extends JPanel
{
int x1,x2,y2,y1,s,l,b;
public drawing()
{
setBackground(Color.CYAN);
addMouseMotionListener(new MouseMotionAdapter()
{
public void mouseDragged(MouseEvent m)
{
x2=m.getX();
y2=m.getY();
repaint();
}
});
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent m)
{
x1=m.getX();
y1=m.getY();
repaint();
}
public void mouseReleased(MouseEvent m)
{
x2=m.getX();
y2=m.getY();
repaint();
}
});

}

public void paint(Graphics g)
{
super.paint(g);
l=Math.abs(this.x1-this.x2);
b=Math.abs(this.y1-this.y2);


if(s==2)
{
g.drawRect(x1,y1,l,b);
}
else if(s==3)
{
g.drawOval(x1,y1,l,b);
}
else if(s==4)
{
g.drawLine(x1,y1,x2,y2);
}
else
{
g.drawString("",10,10);
}
}
}



public class Proj extends JFrame
{
JLabel lab=new JLabel();
drawing d=new drawing();
public Proj()
{
ImageIcon rect=new ImageIcon("image/rect.gif");
ImageIcon ellip=new ImageIcon("image/elli.gif");
JPanel p=new JPanel();
JButton rectangle=new JButton(rect);
JButton ellipse=new JButton(ellip);
JButton line=new JButton("Line");
rectangle.setSize(80,17);

ellipse.setSize(100,17);

line.setSize(100,17);
rectangle.setToolTipText("Entity");
ellipse.setToolTipText("attributes");
line.setToolTipText("links");
p.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
p.add(rectangle);
p.add(ellipse);
p.add(line);
rectangle.setMnemonic('r');
ellipse.setMnemonic('e');
line.setMnemonic('l');
add(p,BorderLayout.NORTH);
add(d,BorderLayout.CENTER);
rectangle.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a)
{
d.s=2;
}
});
ellipse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a)
{
d.s=3;
}
});

line.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a)
{
d.s=4;
}
});
}

public static void main(String args[])
{
Proj pr=new Proj();
pr.setTitle("sample");
pr.setSize(500,500);
pr.setVisible(true);
pr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pr.pack();

}
}