Chirantan (java)
-
Upload
patel-chirantan -
Category
Technology
-
view
276 -
download
1
description
Transcript of Chirantan (java)
Graphics Programing
1. The Graphics class2. The Color class3. The Font class4. The FontMetrics class5. The Dimension class
1. Method of Graphics class
A) drawLine():-:Draw line method used to draw a line.
-:This method draw line joninig the points (x1,y1) and (x2,y2).
Syn: void drawLine(int x1,int y1,int x,int y2);
Ex: g.drawLine(20,30,80,100);
O/P-:
B) drawString():
-:The msg is displayed at the spcified location spcified
by the x and y co-ordinates.
Syn-: void drawString(String msg,int x,int y);
EX-: g.drawString(“JSN”,10,40);
O/P-: JSN
C) drawRect():
-:This method draws a rectangle from the upper-left cornerat the point (x,y)of the width and height specified by which and height.
Syn-: void drawRect(int x,int y,int width,int height
Ex-: g.drawRect(120,60,100,50);
O/p-:
D) fillRect():
-: It draws and fill the rectangle with color.
Syn-: void fillRect(int x,int y,int w,int h);
EX-: g.fillRect(120,60,100,50);
O/P-:
E) drawRoundRect():
-:This method are used to draw a Round Rectangle.
Syn-: void drawRoundRect(int x,int y,int w,int h, int xdia,int ydia);
EX-:g.drawRoundRect(120,60,100,50,100,50);
O/P-:
F) fillRoundRect():
-:It draws and fill the roundrectangle with thecolor.
Syn-: void fillRoundRect(int x,int y,int w,int h, int xdia,int ydia);
EX-: g.drawRoundRect(120,60,100,50,100,50);
O/P-:
G) drawOval():
-: This methods draws an oval.The oval is drawn within the bounding rectangle.
Syn-: void drawOval(int x,int y,int width,int height);
EX-:g.drawOval(120,180,100,50);
O/P-:
H) fillOval():
-:It draws and fills the oval with Color.
Syn-: void fillOval(int x,int y,int width,int height);
EX-: g.fillOval(120,240,75,75);
O/P-:
I) drawPolygon():
-:This method is used to draw a polygon of num of points angles.
Syn-: void drawPolygon(int x[ ],int y[ ],int n);
EX-:int x[ ]={170,220,220,120,120};
g.drawPolygon(x,y,5);int y[ ]={380,430,480,480,430};
O/P-:
J) fillPolygon():
-: It draws and fills the polygon with color.
Syn-: void fillPolygon(int x[ ],int y[ ],int n);
EX-:int x[ ]={170,220,220,120,120};int y[ ]={380,430,480,480,430};g.fillPolygon(x,y,5);
O/P-:
Thank You
Jay Swaminarayan