Repainting/refreshing the JFrame

前端 未结 3 1615
暗喜
暗喜 2021-01-21 07:18

I have a \"car\" made with various objects using graphics g and I want to move it when a button is pressed. With that, I had no problem, but I have a problem with its path. When

3条回答
  •  清歌不尽
    2021-01-21 07:37

    You probably forgot to call

    super.paintComponent(g);
    

    in your paintComponent() method

    @Override
    protected void paintComponent(Graphics g){
        super.paintComponent(g);  //Clear screen before redraw
        //Your codes for painting..
    }
    

提交回复
热议问题