アーわかりませんでした!
class rakugakiFrame extends JFrame{
private int oldx=0,oldy=0;
private JPanel pg;
public rakugakiFrame(){
setSize(400,300);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});

addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent e){
oldx=e.getX();
oldy=e.getY();
}
});

addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent e){
Graphics g=pg.getGraphics();
int x=e.getX();
int y=e.getY();
g.drawLine(oldx,oldy,x,y);
oldx=x;
oldy=y;

}
});

JPanel p=new JPanel();
JButton bt=new JButton("消去");
p.add(bt);
bt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
pg.repaint();
}
});

Container c=getContentPane();
c.add(p,"North");
c.add(pg=new JPanel(),"Center");
pg.setBackground(Color.green);
}
}
こんな感じなんすけどお願いします
ご迷惑をおかけします。