去掉update方法,让它自己处理

解决方案 »

  1.   

    当然啦,你没有清掉原来的图象,改update方法,如下:
    public void update(Graphics g) {
    g.clearRect(0,0,this.getWidth(),this.getHeight());
    paint(g);
    }或者不overriding-update,让repaint自己clear
      

  2.   

    public void paint(Graphics g)
    {
      super(g);
      >>>>>>>>>>>>
    }
      

  3.   

    调用一次public void paint(Graphics g)
    {
    }
    不过将其颜色改为背景色,就可以清除了所有内容了,不过我想这不是ggzzkk (为了你,我要尽全力) 你所要的
      

  4.   

    我赞同beyond_xiruo(希偌)的说法
      

  5.   

    我用了yoyoxo(czm)和beyond_xiruo(希偌)的方法,但还是不行呀。
      

  6.   

    private GridBagLayout gridBagLayout1 = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      private List list1 = new List();
      private Checkbox checkbox1 = new Checkbox();
      private Checkbox checkbox2 = new Checkbox();
      private Button button1 = new Button();
      private Button button2 = new Button();
      private Button button3 = new Button();
      private Button button4 = new Button();
    public void init()
      {
        this.setBackground(new Color(192, 192, 192));
        this.setFont(new java.awt.Font("Dialog", 0, 12));
        setSize(175, 480);
        this.setLayout(gridBagLayout1);//////////////////////////////////////////////////////////////
        gbc.anchor = GridBagConstraints.NORTH;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weightx = 1;
        //gbc.weighty = 1;    gbc.insets = new Insets(2, 4, 0, 4);
        gbc.gridwidth = 2;
        add(new Button("1"), gbc);//////////////////////////////////////////////////////////////
        gbc.gridx = 0;
        gbc.gridwidth = 1;
        checkbox1.setLabel("1");
        add(checkbox1, gbc);
        gbc.gridx = 1;
        checkbox2.setLabel("2");
        add(checkbox2, gbc);    gbc.weighty = 0;
        gbc.gridx = 0;
        gbc.gridwidth = 1;
        button1.setLabel("3");
        add(button1, gbc);
        gbc.gridx = 1;
        button2.setLabel("4");
        add(button2, gbc);//////////////////////////////////////////////////////////////
        gbc.gridx = 0;
        button3.setLabel("5");
        add(button3, gbc);
        gbc.gridx = 1;
        button4.setLabel("6");
        add(button4, gbc);
      }
      public void update(Graphics g)
      {
        g.clearRect(0,0,this.getWidth(),this.getHeight());
        paint(g);
      }  public void paint(Graphics g)
      {
        super.paint(g);
      }