Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好吧,真正的快速问题。我知道 C# Forms 具有 OnPaint() 方法,该方法在渲染时会不断被调用。我知道 Java 也有类似的,但我不知道如何实现它。任何指针或示例(首选)将不胜感激。非常感谢。
如果使用 Swing,请避免在顶级容器中绘画(例如JAppletor JFrame)并使用JComponentor JPanel。
JApplet
JFrame
JComponent
JPanel
对于后两个类中的自定义绘画,请使用paintComponent(Graphics).
paintComponent(Graphics)
Component#paint()方法。
Component#paint()