6.13 (Optional) GUI and Graphics Case Study: Colors and Filled Shapes
Although you can create many interesting designs with just lines and basic shapes, class Graphics
provides many more capabilities. The next two features we introduce are colors and filled shapes. Adding color enriches the drawings a user sees on the computer screen. Shapes can be filled with solid colors.
Colors displayed on computer screens are defined by their red, green, and blue components (called RGB values) that have integer values from 0 to 255. The higher the value of a component color, the richer that shade will be in the final color. Java uses class Color in package java.awt
to represent colors using their RGB values. For convenience, class Color
(package java.awt ...
Get Java How to Program (early objects), 9/e 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.