JApplet - super.paint(); causes flicker

后端 未结 1 546
孤独总比滥情好
孤独总比滥情好 2020-12-07 05:19

I\'m writing a JApplet right now, and whenever I call super.paint(), the applet flickers. I am using double buffering (drawing to an image, and then rendering that image), b

相关标签:
1条回答
  • 2020-12-07 05:42

    Don't use paint and don't draw directly in the JApplet. Instead draw in a JPanel's paintComponent method and call super.paintComponent(g) as the first line of that method. Add that JPanel to your JApplet's contentPane to allow the applet to display it.

    Edit 1
    Also you can't use paintComponents for this as this does something entirely different. Again use paintComponent but only in a component that derives from JComponent such as a JPanel (or a JComponent itself).

    Edit 2 Also always put an @Override above your paintComponent method to be sure that you are in fact overriding the super method.

    0 讨论(0)
提交回复
热议问题