Drawing Geometrical Figures

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.

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…

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…

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…

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.…

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…

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.

setSize(300, 350); To draw…

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…

Java Centered Text with Underline

This code gives strength on AWT graphics programming. There are no predefined methods that can be used straightaway to place the text in the center of the frame and also underline the text. Some programming techniques are required to solve the task. Example on Java Centered Text with Underline The…

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.

Here circle is drawn using drawOval() method. There are other ways to draw circle in Java. Other simple methods used are…

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…

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…

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.…

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…

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,…