Ask Questions?

View Latest Questions

Advertisement


 
 

Drawing
Posted on: July 26, 2006 at 12:00 AM
It is easy to use, and can be used with the Color class to set the drawing color and Font class to set the font for drawing text.

Java Notes

Drawing

The java.awt.Graphics class (see GUI Graphicsis the basis for drawing simple graphics (lines, circles, text, ...). It is easy to use, and can be used with the Color class to set the drawing color and Font class to set the font for drawing text.

Additional graphical classes

In Java 2, there have been many improvements in the graphics capabilities, including the Graphics2D class, classes to represent shapes, easier and more powerful image processing, .... Advanced imaging and 3-D are also being added to Java.

Drawing on a JPanel

To draw, subclass JPanel, and write a paintComponent() method for it. Call repaint() from outside the paintComponent method whenever something has changed and the panel has to be redrawn. Never call repaint from within the paintComponent method or your programs will crash with infinite recursion or produce some pathological flickering.

Copyleft 2003 Fred Swartz MIT License
Advertisement


DMCA.com