drawRect(int x, int y, int width, int height)
是不是把后两项写成了点的坐标,把图画到外面去了

解决方案 »

  1.   

    同意楼上的,
    把你drawRect的语句贴出来?
    看看参数你用什么数字?
      

  2.   

    import java.applet.Applet;
    import java.awt.Button;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    /**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author wanjm
     * @version 1.0
     */public class draw extends Applet {
      Button rect;
      Button circle;
      Applet app;
      public void init()
      {
        app=this;
        rect=new Button("rect");
        rect.addActionListener(new ActionListener()
                               {
          int x=20,y=20;
          public void actionPerformed(ActionEvent evt)
          {
            app.getGraphics().drawRect(x,y,10,10);
            x=x+5;
            y=y+5;
          }
                               });
        circle=new Button("circle");
        circle.addActionListener(new ActionListener()
                               {
          int x=20,y=20;
          public void actionPerformed(ActionEvent evt)
          {
            app.getGraphics().drawOval(x,y,10,10);
            x=x+5;
            y=y+5;
          }
                               });
          add(rect);
          add(circle);  }}
      

  3.   

    点击一下Rect按钮.第一次矩形出不来.
    点击第二次,画出第一个.
    而园则不是.
    请问各位是什么原因.
      

  4.   

    刚刚试了一下,该问题在jdk1.4中存在.
    换成jdk1.3则没有此问题.
    有事为什么?
      

  5.   

    我试过了,很好,没设么问题。画矩形和画园一样。可能是机器有点慢吧,也可能是版本问题。我用的是jdk1.4.1_3+editplus2