Setting Colors
The user can use the Effects menu's Select Color… menu item to set the drawing color used for all drawing operations. When the user selects a drawing color, figures are drawn using that color, even if the user is drawing freehand with the mouse. Solid fills are drawn with that color, and gradient fills are drawn starting with that color and shading off to black. Even text is drawn in the color the user selects.
To let the user select a drawing color, Painter uses a Swing JColorChooser dialog box. This dialog box is easy to put to work, and it has a great deal of utility. Here's all you need to do: Use the JColorChooser class's static showDialog method and store the returned color; Painter stores that value in a Color object named ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access