简单的说,就是想word中添加的矩形一样用鼠标拖动改变位置和大小

解决方案 »

  1.   

    g2.setPaint(background);
    g2.fillrect(0,0,width,height);g2.setPaint(your color);
    g2.fill(rect);
      

  2.   

    Graphics2D g2 = (Graphics2D) g; 
    for(int i=0; i<points.length; i++){ 
    double x = points[i].getX() - SIZE/2; 
    double y = points[i].getY() - SIZE/2;
    Color background = this.getBackground();
    g2.setPaint(background);
    g2.fillRect(0,0,this.getWidth(),this.getHeight());g2.setPaint(Color.black);
    g2.fill(new Rectangle2D.Double(x, y, SIZE, SIZE)); 

    g2.draw(shapeMaker.makeShape(points)); 我编译过了,可以了
      

  3.   

    多谢 feiyasu(飞海) ,你可真是救星。
    能给我个email吗,以后可能还会有时请教