Java how and when exactly is the paint() method called?
问题 I have been told many times that the paint() method will be called as and when required when I extend my class to JFrame but for eg. in the code the paint method is not being called and I don't see any rectangle drawn. I even tried to call paint method inside the constructor (which I created) and then creating an obejct for the class in main but I got a NullPointerException import java.awt.Graphics; import javax.swing.JFrame; public class MyFirstDrawing extends JFrame { /** * */ private