为什么下面的代码在相当于 x=+10 语句连续执行总和的圆圈之前画出很大的空间间隙?
class Panel extends JPanel {
private int x=10;
public void paintComponent( Graphics g ) {
super.paintComponent( g );
g.setColor( Color.MAGENTA );
for (int i=1; i<=8; i++) {
g.drawOval( x, 10, 50, 50 );
x+=10;
}
}
}
public class Circles156 {
public static void main(String[] args) {
JFrame frame = new JFrame( "Drawing lines, rectangles and ovals" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Panel Panel = new Panel();
Panel.setBackground( Color.WHITE );
frame.add( Panel ); // add panel to frame
frame.setSize( 800, 300 ); // set frame size
frame.setVisible( true ); // display frame
}
}