What is wrong with the following code?
Class ExitListener implements ActionListener
{
Public void actionPerformed(ActionEvent event)
{
System.exit(0) ;
}
}
ActionListener exitListener = new ExitListener() ;
JMenu exitMenu = new JMenu("Exit") ;
ExitMenu.addActionListener(exitListener) ;
JMenuBar menuBar = new JMenuBar() ;
MenuBar.add(exitMenu) ;
A) The ExitListener class is not public
B) You cannot attach a listener to a menu, only to a menu item
C) You cannot add a menu to the menu bar, only a menu item
D) You need to use a menu listener, not an action listener
Correct Answer:
Verified
Q62: What is known for certain from this
Q66: Which elements of creating a graphical user
Q69: The documentation for the JSlider class lists
Q72: Based on the statement below, which of
Q72: Which of the following statements is correct?
A)new
Q78: If the user presses and releases a
Q82: The code below will not compile successfully
Q83: Consider the following code snippet:
Class MouseClickedListener implements
Q86: How do the lifetimes of the three
Q87: When method makeMenuItem is called, how many
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents