public void actionPerformed(ActionEvent e) 
{ if(e.getSource()==pen)//画笔 
{toolFlag = 0;} if(e.getSource()==eraser)//橡皮 
{toolFlag = 1;} if(e.getSource()==clear)//清除 

toolFlag = 2; 
paintInfo.removeAllElements(); 
repaint(); 
} if(e.getSource()==drLine)//画线 
{toolFlag = 3;} if(e.getSource()==drCircle)//画圆 
{toolFlag = 4;} if(e.getSource()==drRect)//画矩形 
{toolFlag = 5;} if(e.getSource()==colchooser)//调色板 

Color newColor = JColorChooser.showDialog(this,"调色板",c); 
c = newColor; 
} if(e.getSource()==openPic)//打开图画 
{ openPicture.setVisible(true); if(openPicture.getFile()!=null) 

int tempflag; 
tempflag = toolFlag; 
toolFlag = 2 ; 
repaint(); try{ 
paintInfo.removeAllElements(); 
File filein = new File(openPicture.getDirectory(),openPicture.getFile()); 
picIn = new FileInputStream(filein); 
VIn = new ObjectInputStream(picIn); 
paintInfo = (Vector)VIn.readObject(); 
VIn.close(); 
repaint(); 
toolFlag = tempflag; } catch(ClassNotFoundException IOe2) 

repaint(); 
toolFlag = tempflag; 
System.out.println("can not read object"); 

catch(IOException IOe) 

repaint(); 
toolFlag = tempflag; 
System.out.println("can not read file"); 

} } if(e.getSource()==savePic)//保存图画 

savePicture.setVisible(true); 
try{ 
File fileout = new File(savePicture.getDirectory(),savePicture.getFile()); 
picOut = new FileOutputStream(fileout); 
VOut = new ObjectOutputStream(picOut); 
VOut.writeObject(paintInfo); 
VOut.close(); 

catch(IOException IOe) 

System.out.println("can not write object"); 



}//end paintboard