Java Swing drawing disappears when resizing window

前端 未结 4 1837
刺人心
刺人心 2021-01-14 06:23

i need your help badly because i cannot solve this problem on my own. I am trying to create a GUI and want to draw something in it after pressing a button, but i seem to ha

4条回答
  •  终归单人心
    2021-01-14 06:44

    I did not went through all of your code, but what is immediately visible is that you should not override the paintComponent method without calling super.paintComponent. And your commented out line calls super.paintComponents (note the s), which is not the same.

    I am also unsure what you mean 'when I resize the window', and how that is tied together with your Jpanel1.setSize( 1000, 1000 ) calls which appear all over your code. Your layout manager will take care of the size of the panel. You should not set that to a fixed size.

提交回复
热议问题