Quiz 10

Friday

With a piece of paper, write down your name and answers to the following questions.

  1. What method do you use to make a text field, JTextField, read-only?

    1. setChangeable(false)
    2. setEditable(false)
    3. setReadOnly(true)
    4. setUneditable(true)
  2. Which of the following is the name of a small box that contains text and appears when the mouse is hovered over a component.

    1. mnemonic
    2. pop-up help
    3. instance message
    4. tool tip
  3. Describe what the following program does.

    1. What is displayed in the window?

      The window it titled as “Quiz #10 Question #4”. The window contains a button with text “Button” and a text area.

    2. What happens when the button is pressed?

      When the button is clicked, a new line of text, “Hello”, is appended to the text area.

    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.JTextArea;
    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() {
        final MainWindow window = new MainWindow();
        window.setVisible(true);
      }
    }

    final class MainWindow extends JFrame {

      JButton button = new JButton("Button");
      JTextArea area = new JTextArea(20, 20);

      public MainWindow() {
        super("Quiz #10 Question #4");

        this.setLayout(new FlowLayout());
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        this.add(this.button);
        this.add(this.area);
        this.pack();

        this.button.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final String oldText = MainWindow.this.area.getText();
            MainWindow.this.area.setText(oldText + "Hello\n");
          }
        });
      }
    }

Student Performance and Statistics

A histogram of student performance on percentage grades for Quiz 10 on Friday.

100% 1 90 - 99% 0 80 - 89% 7 70 - 79% 1 60 - 69% 0 50 - 59% 1 40 - 49% 0 30 - 39% 0 20 - 29% 0 10 - 19% 0 0 - 9% 0

A table showing the average performance for each question in Quiz 10 on Friday.

Q1 0.9 / 1 Q2 1.0 / 1 Q3 2.0 / 3