简体   繁体   English

OnPaint()for Java?

[英]OnPaint() for Java?

All right real quick question guys. 好吧,快速问题的人。 I know that C# Forms have the OnPaint() method that keeps on being called when its time to render. 我知道C#Forms具有OnPaint()方法,该方法在渲染时保持被调用。 I know Java has a similar one but I am lost on how to implement it. 我知道Java有一个类似的但我对如何实现它感到迷茫。 Any pointers or example(prefferred) will be very much appreciated. 任何指针或示例(prefferred)将非常感激。 Thanks a lot. 非常感谢。

If using Swing, refrain from painting in a top level container (eg JApplet or JFrame ) and use a JComponent or JPanel . 如果使用Swing,请避免在顶级容器(例如JAppletJFrame )中绘画,并使用JComponentJPanel

For custom painting in the latter two classes, use paintComponent(Graphics) . 对于后两个类中的自定义绘画,请使用paintComponent(Graphics)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM