Series: AWT Graphics

Java graphics with all geometrical figures drawn explained in simple terminology for a beginner

Java Graphics Tutorial

Java Graphics Tutorial Summary: In this tutorial "Java Graphics Tutorial", you will come to know of Java graphics concepts like frame and its coordinate system, Graphics class etc. This understanding is very necessary for future programs. The term Graphics is derived from the Latin word Graphicus. Graphics involves drawing various geometrical figures like rectangles, polygons, …

Java Graphics Tutorial Read More »

Java Draw Rectangle Applet graphics

Java supports graphics through applications (extends Frame) and applets (extending Applet). We have seen drawing rectangles through applications and now let us convert the same rectangle application into an applet program. To go throug this code, it is required to have the knowledge of applets, applet life cycle methods and drawing strings on applet window. …

Java Draw Rectangle Applet graphics Read More »

Java Graphics Draw Lines

Java Graphics Draw Lines Summary: By the end of this tutorial "Java Graphics Draw Lines", you will come to know the drawing of lines on frame. Drawing graphics is very simple in Java. The line drawing takes four parameters of starting point x and y coordinates and ending point x and y coordinates. Supporting method …

Java Graphics Draw Lines Read More »

Java Drawing Strings Colors Fonts

Java Drawing Strings Colors Fonts Summary: By the end of this tutorial "Java Drawing Strings Colors Fonts", you will come to know to draw strings in different colors and fonts in graphics. In the "Drawing Strings" program, the strings are drawn in default black color and with font Dialog. Now, let us redraw the strings …

Java Drawing Strings Colors Fonts Read More »

Java AWT Drawing Strings Frame

Graphics class allows us to draw strings on the frame with its method drawString(). Following is the signature. void drawString(String str1, int x, int y): x and y are the coordinates where the string str1 is to be drawn on the frame. Following program illustrates. import java.awt.*; public class StringsDrawing extends Frame { public StringsDrawing() …

Java AWT Drawing Strings Frame Read More »

Java Draw Rectangles

Java Draw Rectangles Summary: In this tutorial "Java Draw Rectangles", you learn how much it is easy to draw rectangles in Java. Drawing Rectangles 3 types of rectangles Java supports Right-angled rectangles Round-cornered rectangles 3-D Rectangles Java requires width and height of the rectangle and x and y coordinates where rectangle (top left corner position) …

Java Draw Rectangles Read More »

Java Draw Round Cornered Rectangles

Drawing Rectangles Java graphics supports 3 types drawing rectangles. 1. Right-angled rectangles 2. Round-cornered rectangles 3. 3-D Rectangles Java requires width and height of the rectangle and x and y coordinates where rectangle is be drawn. Java does not include a special method, something like drawSquare(), to draw a square. Square can be drawn with …

Java Draw Round Cornered Rectangles Read More »

Java Draw 3 D Rectangles

Drawing Rectangles Java graphics supports 3 types drawing rectangles. Right-angled rectangles Round-cornered rectangles 3-D Rectangles Java requires width and height of the rectangle and x and y coordinates where rectangle is be drawn. Java does not include a special method, something like drawSquare(), to draw a square. Square can be drawn with rectangle method only …

Java Draw 3 D Rectangles Read More »

Java Draw Ovals

Java Draw Ovals Summary: In this tutorial "Java Draw Ovals", you learn drawing of drawing ovals in Java graphics. After learning rectangles drawing, let us see the oval. Oval (Latin: Ovum meaning egg) is an elliptical shape rounded at both ends. Supporting methods from java.awt.Graphics class void drawOval(int x, int y, int width, int height); …

Java Draw Ovals Read More »

Java Graphics Draw Arcs

A segment of an oval is an arc. The arc angle can be positive (sweeps anti-clockwise) or negative (sweeps clockwise). As with other figures, the arcs can be outline or solid. Supporting methods from java.awt.Graphics class void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle): draws an outline arc. void fillArc(int …

Java Graphics Draw Arcs Read More »

Java Drawing Arrays Graphics

Java Drawing Arrays Graphics Summary: By the end of this tutorial "Java Drawing Arrays Graphics", you will be comfortable in drawing arrays with graphics. Apart other graphics, Java also supports drawing characters from character and byte arrays. Java comes with an option of drawing complete array or part of the array. Supporting methods from java.awt.Graphics …

Java Drawing Arrays Graphics Read More »

Java Draw Images Graphics

Java Draw Images Graphics Summary: Java permits to draw images in graphics. Explained in this tutorial "Java Draw Images Graphics" in simple terms, code and screenshot. Go through. To draw images, the Graphics class includes a method drawImage(). Drawing images requires special coding using ImageObserver. 2. Drawing Images in Applications (Frames) After seeing how to …

Java Draw Images Graphics Read More »

Java Graphics Draw Polygons Applets

A polygon is a closed figure with many lines joined one to another. The ending point of one line is the starting point to another line and finally the last point is joins with the first point. java.awt.Graphics class comes with two methods and one constructor to draw polygons. void drawPolygon(int x[], int y[], int …

Java Graphics Draw Polygons Applets Read More »

Java Draw Cylinder Cube Circle

There are no predefined methods to draw a cylinder, cube and circle. Using existing methods of Graphics class like drawOval(), drawRect(), drawArc() etc., the task can be done. import java.awt.*; import java.awt.event.*; public class SpecialFigures extends Frame { public SpecialFigures() { setTitle(“Special Effects”); setSize(450,550); setVisible(true); } public void paint(Graphics g) { // to draw a …

Java Draw Cylinder Cube Circle Read More »

Java Draw Circles Graphics Applets

No special or predefined method exists with Graphics class to draw circles. But still, circles can be drawn in three styles using other methods. Using drawRoundRect() Using drawOval() – most preferred Using drawArc() All the earlier programs like drawing rectangles are illustrated with Frame. Now let us go for applet. Applet includes init(), start() and …

Java Draw Circles Graphics Applets Read More »

Java Retrieve Color Information

Java Retrieve Color Information Summary: Apart using colors in graphics, you can retrieve the information of the components of Color object. Comfortable to read in simple terms in "Java Retrieve Color Information". We have learnt about Color class, how to create Color objects both RGB and HSB models and the predefined colors Java supports. Now …

Java Retrieve Color Information Read More »

Java Graphics Draw Hut Man

Following is a good program giving command over graphics. First imagine rough coordinates, after seeing the figure, adjust the coordinates. import java.awt.* ; import java.awt.event.* ; public class Hut extends Frame { public Hut() { setBackground(Color.cyan); setTitle(“House to live by SNRao”); setSize(450,350); setVisible(true); addWindowListener(new WindowAdapter() { // for frame closing public void windowClosing( WindowEvent e …

Java Graphics Draw Hut Man Read More »