import java.awt.Graphics;
import javax.swing.*;

public class Shape extends JApplet {

int choice;

public void init()
{

String input;

input= JOptionPane.showInputDialog( "enter 1 to draw line\n" + "enter 2 to draw rectangles\n" + "enter 3 to draw ovals\n" );

choice= Integer.parseInt( input );

}

public void paint( Graphics g )
{

for ( int i= 0; i < 10; i++ )
{

switch( choice )
{
case 1:
g.drawLine( 10, 10, 250, 10 + i * 10 );
break;

case 2:
g.drawRect( 10 + i * 10, 10 + i  * 10, 50 + i * 10, 50 + i * 10 );
break;

case 3:
g.drawOval( 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 );
break;

default:
JOptionpane.showMessageDialog( null, "invalid value entered" );

}
}
}
Hosted by www.Geocities.ws

1