Professional Documents
Culture Documents
<CO5>: <22142>: <Java Programming>: <Develop program for implementing given geometric shape>: <UO3>: <Study Material>
Graphics class –
drawline () method
Syntax:
drawLine(int x1, int y1, int x2, int y2)
Result: This method will draw a line starting from (x1, y1) co-
ordinates to (x2, y2) co-ordinates.
drawRect () method-
Syntax:
drawRect(x,y,w,h);
Result: This method will draw a rectangle starting from (x, y) co-
ordinates with specified width and height
Solved word drawOval () method-
Problem Syntax:
Explain execution
of applet life cycle drawOval(int x1,int y1, int width, int height)
with help of
example? Parameters: The drawOval method takes four arguments:
x1 –point’s x coordinate.
y1 –point’s y coordinate.
width – width of oval
height – Height of oval
Result: This method will draw Oval starting from (x1, y1) co-
ordinates with specified width and height
fillOval () method-
Syntax:
fillOval(int x1,int y1, int width, int height)
Result: This method will draw an Oval starting from (x1, y1) co-
ordinates with specified width and height. This drawn Oval will be
filled with set foreground color.
Explanation of concept:
drawArc () method-
Syntax:
drawArc(int x, int y, int w, int h, int sa, int aa)
Result: This method draws an arc starting from (x1, y1) co-ordinates
with specified width and height and with specified starting angle and
arc angle around it.
fillOval () method-
Syntax:
fillArc(int x, int y, int w, int h, int sa, int aa)
Result: This method draws an filled arc starting from (x1, y1) co-
ordinates with specified width and height and also with specified
starting angle and arc angle around it.
drawPolygon () method-
Syntax:
drawPolygon(xp,yp,n)
fillPolygon()method-
Syntax:
fillPolygon(xp,yp,n)