Java Swing drawing disappears when resizing window

前端 未结 4 1835
刺人心
刺人心 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:48

    When you resize your panel or change it position or minimize it and maximize it, a paint(...) method is called that repaints the content. You have to overwrite this function and let it paint your line or what ever. To do this, you must probably save your drawing in a data-structure to be able to repaint it when every necessary.

    The paint method is described here.

提交回复
热议问题