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 do it:
The math behind that program may be a bit baffling. This diagram might help. The techinque for computing the rounding uses elementary geometry, the pythagorean theorem, and elementary trigonometry.
|
|
You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) |
| http://mindprod.com/jgloss/graphicsobject.html | J:\mindprod\jgloss\graphicsobject.html | |
![]() | Please email your feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording,
broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.179.213] | |
| Feedback | You are visitor number 16,215. | |