Quiz 11
Wednesday
With a piece of paper, write down your name and answers to the following questions.
What method do you use to place a
JMenuBar
on aJFrame
?setJMenuBar
placeJMenuBar
addJMenuBar
insertJMenuBar
What is the default selection mode for
JList
?- single selection
- multiple selection
- single interval selection
- multiple interval selection
Describe what the following program does.
What is displayed in the window?
The window it titled as “Quiz #11 Question #4”. The window contains a button with text “Button”.
What happens when the button is pressed?
When the button is clicked, a message window appears, centered on top of the main window. This popup window is titled as “Popup Message” and it contains a message “Hello World”.
import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; public final class Program implements Runnable { public static void main(String[] args) { SwingUtilities.invokeLater(new Program()); } @Override public void run() { MainWindow window = new MainWindow(); window.setVisible(true); } } final class MainWindow extends JFrame { public MainWindow() { super("Quiz #11 Question #4"); this.setLayout(new FlowLayout()); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); final JButton button = new JButton("Button"); this.add(button); this.pack(); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( MainWindow.this, "Hello World", "Popup Message", JOptionPane.PLAIN_MESSAGE); } }); } }
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 11 on Wednesday.
A table showing the average performance for each question in Quiz 11 on Wednesday.