private void saveAs(){
      if(dMenuItemSaveAs.isEnabled()){
          //get the save file name 
          FileDialog fd=new FileDialog(dWhiteboardFrame,"Save as",FileDialog.SAVE);
          fd.setModal(true);
          fd.show();
          String fileName=null;
          if(fd.getDirectory()==null) return;
	  if(fd.getFile()==null) fileName=null;
	  else
	    fileName=fd.getDirectory()+fd.getFile();

          Component[] shapes=dShapeContainer.getComponents();
          //remove shape controller from the shap listener list
          try{
             for(int i=0; i<shapes.length;i++){
                shapes[i].removeMouseListener(this);
                shapes[i].removeMouseMotionListener(this);
             }
          }catch(NullPointerException e){}
          
          
          //open a file to write
   
          try{
	    ObjectWriter writer=ObjectWriter.openFileForWriting(fileName);        
             writer.writeObject(shapes);
             dMenuItemSaveAs.setEnabled(false);
             writer.close();
          }catch(NullPointerException eP){
             String title="Warning",
                   message="Can not open file for writing!";
             boolean isModal=true;
             new MyMessageBox(dWhiteboardFrame,title,message,isModal);
             return;
          }
      }
  }