// Fig 5.1: WhileCounter.java
// Counter-controlled repetition

// Java core packages
import java.awt.Graphics;

// Java extension packages
import javax.swing.JApplet;

public class WhileCounter2 extends JApplet {
	//draw lines on the applet's backgrouns
	public void paint ( Graphics g )
	{
		//call inherited version of the method paint
		super.paint( g );
		
		int counter = 0;		// initialization
		
		while ( counter <= 25 )	//repetition condition
		{
			g.drawLine( counter * 10, 250, 250, 250 - counter * 10 );
			g.drawLine( 250, counter * 10, 250 + counter * 10, 250 );
			g.drawLine( counter * 10, 250, 250, 250 + counter * 10 );
			g.drawLine( 250, 250 + counter * 10, 500 - counter * 10, 250 );
			++counter;			// increment
		}	// end while structure
	}	// end method paint
}	// end class WhileCounter