
924 CHAPTER 12 Graphical User Interfaces
EXERCISES,PROBLEMS, AND PROJECTS
For Questions 22 to 26, consider the following code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Game extends JFrame
{
private JCheckBox c1, c2, c3;
private int value1, value2, value3;
private Container contents;
public Game()
{
super( ”Play this game“ );
contents = getContentPane();
contents.setLayout( new FlowLayout());
c1 = new JCheckBox( ”Choice 1“ );
c2 = new JCheckBox( ”Choice 2“ );
c3 = new JCheckBox( ”Choice 3“ );
contents.add( c1 );
contents.add( c2 );
contents.add( c3 );
MyHandler mh = new MyHandler();
c1.addItemListener( mh );
c2.addItemListener