Rewrite the program in Listing 13.9 so that the panel with the buttons changes to pink when the larger panel turns red. Similarly, when the larger panel turns green, the panel with the buttons changes to blue. Also add a label to the larger panel that says Watch this panel!, and add a button to the button panel that is labeled Change. When the Change button is clicked, the colors change (from pink and red to blue and green, respectively, or vice versa). The Change button has no effect on the initial configuration, in which the big panel is blue and the button panel is gray.

This program can be written by making a few changes to PanelDemo, Listing 13.9. One little extra detail is that buttonPanel must be visible in the actionPerformed method, so it is declared outside the constructor block. A character flag is used to keep track of the background color settings so the click-on-Change event can determine the new background colors (and not change them if they are the initial colors).


See the code in PanelDemo2.java. Uses WindowDestroyer.java.

Computer Science & Information Technology

You might also like to view...

A(n) _____ is an HTML code, not visible on a displayed Web page, that contains keywords representing the Website's content, which search engines use to build indexes pointing to the Website.

A. attribute B. meta tag  C. hyperlink text D. identifier

Computer Science & Information Technology

The binary number system uses only two digits: 0 and 1.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Use caution when assigning a shortcut key to a macro so you do NOT override an existing shortcut within Excel

Indicate whether the statement is true or false

Computer Science & Information Technology

You have just brought online a new secondary DNS server and notice your network-monitoring software reports a significant increase in network traffic. Which two hosts on your network are likely to be causing the increased traffic and why?

a. The root and primary DNS servers, because the primary server is requesting zone transfers from the root server b. The web server and primary DNS server, because the web server is requesting zone transfers from the primary DNS server c. The caching and primary DNS servers, because the caching server is requesting zone transfers from the primary server d. The secondary and primary DNS servers, because the secondary server is requesting zone transfers from the primary server

Computer Science & Information Technology