AWT Graphics in Java

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 Geometrical Figures

Java Graphics Geometrical Figures Check out, your one-stop destination for all Java Geometrical Figures. Java Graphics coordinate Structure: Graphics – Introduction. Drawing Figures both Outline and Filled: Lines, Strings with colors and fonts, Right-angled rectangles, Round-cornered rectangles, 3-D Rectangles, Ovals, Arcs, Polygons. Array Drawing: Complete and partial array elements. Special…

Java FontMetrics Factory Methods

java.awt.FontMetrics is an abstract class that maintains the metadata of a font. The metadata includes such information how font letters should adjust with the previous line and next line. The characters like h, p, l, j etc have some special attention in adjusting with other characters in the line. The…

class Toolkit Get Font List

class Toolkit Get Font List Summary: In this tutorial "class Toolkit Get Font List", explained usage of ToolKit class to get font list supported by Java graphics. java.awt.Toolkit is an abstract class and can be used by the programmer to interact with the operating system to know some data supported…

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 Create Color

Java Create Color Summary: By the end of this tutorial "Java Create Color", you can create a Color object with different color components. Explained in simple terms. Go further The best way to present the graphics is in good attractive colors and fonts. Colors and fonts give readability and emphasis…

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…

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 Retrieve Font Information

Java Retrieve Font Information Summary: By the end of this tutorial "Java Retrieve Font Information", you will be comfortable to retrieve the components of Font object like font name, style and size. The Font object (discussed earlier) comprises of three components – font name as string, font style and font…

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…

Java Clear Copy Graphics Area

java.awt.Graphics class comes with many methods of drawing and also with some non-drawing methods that will support drawing indirectly. These methods include clearRect() and copyArea() etc. clearRect() clears a part of graphical area where a drawing may exist with its own background. When cleared, the cleared area shows the background…

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…