Chirantan (java)

12
Graphics Programing 1. The Graphics class 2. The Color class 3. The Font class 4. The FontMetrics class 5. The Dimension class

description

java

Transcript of Chirantan (java)

Page 1: Chirantan   (java)

Graphics Programing

1. The Graphics class2. The Color class3. The Font class4. The FontMetrics class5. The Dimension class

Page 2: Chirantan   (java)

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-:

Page 3: Chirantan   (java)

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

Page 4: Chirantan   (java)

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-:

Page 5: Chirantan   (java)

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-:

Page 6: Chirantan   (java)

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-:

Page 7: Chirantan   (java)

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-:

Page 8: Chirantan   (java)

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-:

Page 9: Chirantan   (java)

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-:

Page 10: Chirantan   (java)

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-:

Page 11: Chirantan   (java)

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-:

Page 12: Chirantan   (java)

Thank You

Jay Swaminarayan