Why doesn't the following code compile correctly?

```
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ColorCheckBoxWindow extends JFrame
{
private JCheckBox greenCheckBox;
private final int WINDOW_WIDTH = 300, WINDOW_HEIGHT = 100;
public ColorCheckBoxWindow()
{
setTitle("Green Check Box");
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
greenCheckBox = new JCheckBox("Green");
greenCheckBox.addItemListener(new CheckBoxListener());
setLayout(new FlowLayout());
add(greenCheckBox);
setVisible(true);
}
public void itemStateChanged(ItemEvent e)
{
if (e.getSource() == greenCheckBox)
{
System.exit(0);
}
}
}

```

A) ColorCheckBoxWindow is not implementing the correct listener.
B) The button cannot be added to the content pane.
C) The itemStateChanged method cannot be coded here.
D) greenCheckBox should not be a private member.


C) The itemStateChanged method cannot be coded here.

Computer Science & Information Technology

You might also like to view...

Which region is used by default when a Component is added to a BorderLayout?

a. NORTH b. CENTER c. WEST d. LEFT

Computer Science & Information Technology

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

1. A stream is a flow of data into or out of your program. 2. An input stream is a stream of data flowing from your program, either to a file, or to the keyboard. 3. An output stream is a stream of data flowing from your program, to a file, a device of some sort such as the screen. 4. cin is an output stream object of type ostream. 5. When a program sends data from itself to the outside, say to a file or the screen, we say it is writing the data on the file or to the screen.

Computer Science & Information Technology

AC Case 1-1Ms. Lipscomb is a high school counselor who manages senior students' records. She is responsible for keeping track of course records, grades, tests taken, and prospective colleges. She would like to create a database in Access to manage all of this data. When setting the default database folder to store the database, Ms. Lipscomb would select which of the following on the left side of the the Access Options dialog box?

A. Client Settings B. Datasheet C. Current Database D. General

Computer Science & Information Technology

?Columns and column groups accept only CSS style properties to modify the column borders, background, width, and visibility.

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

Computer Science & Information Technology