The JDisplay Java Applet
displays the large program listings on this web page.
JDisplay requires an up-to-date
browser and Java version
1.8+, preferably 1.8.0_112.
If you can’t see the listings, or if you just want to learn
more about JDisplay, click
here for help.
Use Firefox for best results.
The Graphics class is abstract. It is just a collection of
specifications for low-level drawing methods. The graphics object also contains a
reference to the area of ram where the bit image will be constructed and it also
contains the current clipping region. It is used for all types of painting including
placing components, canvas drawing and laying out text.
The most often use the Graphics object is as a
parameter to your paint, paintComponent or print method. You often
cast the abstract Graphics to an actual Graphics2D object to access additional methods. Have a look at the
Screws application to
understand the basics of drawing.
Graphics has methods drawRoundRect and drawRoundRect to draw
rectangles with rounded corners, but there are no built-in methods to do the same for
arbitrary polygons, including triangles. Here is the code taken from the connectors downloadable package to
The math behind that program may be a bit baffling. This diagram might help. The
technique for computing the rounding uses elementary geometry, the Pythagorean
theorem and elementary trigonometry.
Oracle’s Javadoc on Graphics.drawString : the Graphics. drawString method behaves differently from other drawing methods. Usually the x,y is the upper left corner. For drawString, it is the left end of the string baseline. : available:
Oracle’s Javadoc on Graphics.drawArc : Beware. Angles are measured in degrees counter clockwise from 3 o’clock. It does not take start and end angle but start angle and arc size in degrees (end-start). Angles may be negative. : available:
Oracle’s Javadoc on Graphics.fillArc : Beware. Angles are measured in degrees counter clockwise from 3 o’clock. It does not take start and end angle but start angle and arc size in degrees (end-start). Angles may be negative. : available: