//Li Yuet Cheung 010526474 Gorup:2W Number:11

/*This is a Java Applet Program to initialize input dialog boxes to collect information of drawing a
  rectangle. Finally, it can be output to the HTML file.
*/

//import some java core and extension packages
import javax.swing.JOptionPane;
import java.awt.Graphics;
import javax.swing.JApplet;


public class Rectangle extends JApplet {

	//Initialize public variable
			int int_left_x;  		//Integer format of left x coordinate of the Rectangle
			int int_left_y;			//Integer format of left y coordinate of the Rectangle
			int int_width;			//Integer format of width of the Rectangle
			int int_height;			//Integer format of height of the Rectangle

			String string_left_x;	//String format of left x coordinate of the Rectangle
			String string_left_y;	//String format of left y coordinate of the Rectangle
			String string_width;	//String format	of width of the Rectangle
			String string_height;	//String format of height of the Rectangle

	//Initialize Method to collect information  for drawing the Rectangle
	public void init(){
		//Input the left x coordinate of the Rectangle
		string_left_x =
		JOptionPane.showInputDialog(" Enter Left X: ");

		//Input the left y coordinate of the Rectangle
		string_left_y =
		JOptionPane.showInputDialog(" Enter Left Y: ");

		//Input the width of the Rectangle
		string_width =
		JOptionPane.showInputDialog(" Enter Width: ");

		//Input the height of the Rectangle
		string_height =
		JOptionPane.showInputDialog(" Enter Height: ");

		//Change data type of variable from String to Integer
			int_left_x = Integer.parseInt(string_left_x);
			int_left_y = Integer.parseInt(string_left_y);
			int_width = Integer.parseInt(string_width);
			int_height = Integer.parseInt(string_height);
	}

	//The function of this Method is to draw a rectangle
	public void paint( Graphics g){

		//call inherited version of method paint
		super.paint(g);

		//draw a rectangle starting form (x coordinate, y coordinate, width, height)
		g.drawRect(int_left_x,int_left_y,int_width,int_height);
	}
}