Why does this while loop prevent paint method from working correctly?
问题 Here's my code: package javaapplication2; import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class JavaApplication2 extends JPanel { public static void main(String[] args) { JFrame frame = new JFrame("Simple Sketching Program"); frame.getContentPane().add(new JavaApplication2()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setVisible(true); } @Override public void paint(Graphics g) { g.setColor