Chapter 2
Drawing Shapes
In This Chapter
Creating basic shapes such as lines, rectangles, and ellipses
Setting the fill color and stroke thickness
Creating shapes you can see through
Creating gradient fills
Rotating shapes
Drawing text onscreen
Were you one of those kids who, way back in school, passed away the boring hours of algebra class by doodling in the margins of the book? If so, you're in luck. Now that you're a grownup and you're mastering Java programming, you don't have to doodle in the book. Instead, you can write programs that doodle onscreen.
This chapter is a gentle introduction to the fascinating world of drawing in Java. The designers of Java call this feature Java 2D. With Java 2D, you can draw basic shapes: lines, arcs, rectangles, ellipses, and so on. You can set the style used to draw the shape's outline, and you can fill the shape with a solid color, a gradient ...
Get Java All-in-One For Dummies, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.