比如我先绘制了一个矩形后有绘制了一个圆,我现在想把矩形删除掉,应该如何做?急,谢谢大伙。

解决方案 »

  1.   

    哦,WIN SDK的术语,看着眼熟,忘了。你的问题不难,但是,不知道你当前是怎么处理的。比如,你是怎么显示矩形或圆形的?
      

  2.   

    QB里面有画圆,擦园...不知道JAVA有没有
      

  3.   

    应该有一个集合来保存你的图元,下面是一些思路:ArrayList<Shap> mapList=ArrayList<Shap>();mapList.add(new Rectangle(50,50,100,100));
    mapList.add(new Ellipse(50,50,100,100));//写一个函数处理选中
    public synchronized Shap getSelShap(Point mousePoint){ 
      Shap sel=null;
      
      for(Shap item : mapList){
         if(item.contains(mousePoint)){
            sel=item;
            break;
         }
      }
    }//从list中删除图元
    mapList.remove(getSelShap(new Point(x,y));
    repaint();//绘制
    public void paint(Graphics g){
       for(Shap item : mapList){
          g.draw(item);
       }
    }