Java ppt
Java ppt
GRAPHICS PROGRAMMING
1 Presented by
Pooja Rani
GNKC, YNR
INTRODUCTION
Main feature in java is creating a graphical interface .
Graphics in any language gives a wonderful look and feel to
the users .
Applet package
awt package
2
APPLET
An applet is a Java program that runs in a Web browser
3
EXAMPLE APPLET PROGRAM
5
AWT PACKAGE
The Abstract Window Toolkit (AWT)
It is Java's original platform-independent windowing,
graphics, and user-interface toolkit.
6
GRAPHICS CLASS
Graphics class include methods for drawing shapes , images
to the screen inside your applet
7
DRAWING STRING IN APPLET
drawString()
drawString() is used to display string in Graphical area.
SYNTAX
String to be displayed
8
DRAWING LINES
drawLine()
This method is used to draw a line.
SYNTAX
9
drawPolyline()
It connects the xPoints and yPoints arrays
SYNTAX
10
SAMPLE CODE
11
OUTPUT
12
DRAWING SHAPE PRIMITIVES
drawRect()
Used to draw rectangle shape in an applet.
SYNTAX
SYNTAX
14
drawArc()
Arc is same as oval
SYNTAX
15
drawRoundRect()
By using this method we can draw rounded rectangle
SYNTAX
drawRoundRect(int xTopLeft, int yTopLeft, int width, int
height, int arcWidth, int arcHeight)
SYNTAX
17
SAMPLE CODE
18
OUTPUT
19
FILLING PRIMITIVE SHAPES
fillOval()
The fillOval() method draws a filled oval .
SYNTAX
SYNTAX
fillArc(int xTopLeft, int yTopLeft, int width, int height, int
startAngle, int arcAngle);
21
fillRect()
fillRect() method draws a filled .
The filled rectangle is one pixel smaller to the right and
bottom than requested.
SYNTAX
22
fillPolygon()
The fillPolygon() method draws a polygon.
If xPoints or yPoints does not have numPoints elements, it
throws the run-time exception
andIllegalArgumentException.
SYNTAX
SYNTAX
25
OUTPUT
26
setColor( )
AWT color class used to specify any color we need.
EX:
g.setColor(Color . yellow);
27
SAMPLE CODE
28
OUTPUT
29
THANK YOU
30