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...

To access files from a C++ program, you must #include

A) . B) . C) . D) . E) None of the above

Computer Science & Information Technology

Text messaging includes all of the following except ________ .

A. cloud computing B. instant messaging C. chat D. text messaging

Computer Science & Information Technology