Page 711 - Introduction to Programming with Java: A Problem Solving Approach
P. 711
Figure 16.13 Sample sessAionpfoar tghe oColorPChDoosFer prEogrnamhancer
need to use a substantial amount of all three color values. That should make sense when you realize that
whiteisColor(255, 255, 255).
16.16 Color 677
Initial display:
After clicking the Gray button:
After clicking the Blue button:
/**********************************************************
*
ColorChooser.java
Dean & Dean
This program's buttons allow the user to set the window's
background color to gray or blue.
**********************************************************/
*
*
*
*
import javax.swing.*;
// for JFrame & JButton
// for FlowLayout, Color, & Container
// for ActionListener & ActionEvent
public class ColorChooser extends JFrame
import java.awt.*;
import java.awt.event.*;
{
private static final int WIDTH = 300;
private static final int HEIGHT = 100;
private JButton grayButton; // changes background to gray
private JButton blueButton; // changes background to blue
Figure 16.14a ColorChooser program—part A