JPanel Graphics clearing and repainting?

前端 未结 4 610
情书的邮戳
情书的邮戳 2020-12-16 20:25

I have a JPanel with a paintComponent() function. I\'ll call it once, then when the user clicks a different JButton, I\'ll set some fl

4条回答
  •  臣服心动
    2020-12-16 20:35

    I would suggest calling revalidate(); instead of repaint(). revalidate() needs to be called when changing the size / layout or when you add/remove objects onto your jpanel and will update all of it's children. From what I can tell, you're still using the same paint object tho but changing it's layout.

提交回复
热议问题