OOPR212 Java Event Handling: Inheritance Hierarchy Quiz
29 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What method in the MouseEvent class returns the number of mouse clicks associated with the event?

  • int getX()
  • int getButton()
  • int getY()
  • int getClickCount (correct)
  • Which MouseEvent event method provides the x-position of the event relative to the source component?

  • MOUSE_ENTERED
  • MOUSE_DRAGGED
  • getX() (correct)
  • MOUSE_CLICKED
  • In the JList Class, what is used to construct a JList object?

  • A character
  • An integer
  • A boolean
  • An array of Strings (correct)
  • Which MouseEvent method returns which, if any, of the mouse buttons has changed state?

    <p>int getButton()</p> Signup and view all the answers

    What type of event serves as an indication that the mouse pointer has exited a component?

    <p>MOUSE_EXITED</p> Signup and view all the answers

    Which method would you use to find the largest selected cell index in a JList?

    <p>getMaxSelectionIndex()</p> Signup and view all the answers

    When would you use the method setSelectedIndex(int index) in a JList?

    <p>To select a single cell</p> Signup and view all the answers

    Which type of JScrollPane constructor would you need if you want to create a JScrollPane with both horizontal and vertical scroll bars that appear when needed, but start empty?

    <p>JScrollPane()</p> Signup and view all the answers

    What does the method isSelectionEmpty() return when nothing is selected in a JList?

    <p>True</p> Signup and view all the answers

    Which JList method would you use to determine whether single-item or multiple-item selections are allowed?

    <p>getSelectionMode()</p> Signup and view all the answers

    In a JList, what does the method getFirstVisibleIndex() return?

    <p>Index of the first visible cell</p> Signup and view all the answers

    Which method is not invoked when the mouse button has been clicked on a component?

    <p>mouseEntered(MouseEvent e)</p> Signup and view all the answers

    Which method is invoked when the mouse cursor has been moved onto a component but no buttons have been pressed?

    <p>mouseMoved(MouseEvent e)</p> Signup and view all the answers

    Which static int of MouseEvent class indicates no mouse buttons?

    <p>NOBUTTON</p> Signup and view all the answers

    Which interface includes all the methods in both the MouseListener and MouseMotionListener interfaces?

    <p>MouseInputListener</p> Signup and view all the answers

    Which method is invoked when the mouse button is pressed on a component and then dragged?

    <p>mouseDragged(MouseEvent e)</p> Signup and view all the answers

    Which method is not invoked when the mouse button is released on a component?

    <p>mouseEntered(MouseEvent e)</p> Signup and view all the answers

    What is a requirement for the class of an object that responds to an event?

    <p>It must contain a method that accepts the event object</p> Signup and view all the answers

    What does the getModifiers() method of the MouseEvent class return?

    <p>An integer indicating which mouse button was clicked</p> Signup and view all the answers

    Which interface provides methods named mouseDragged() and mouseMoved()?

    <p>MouseMotionListener</p> Signup and view all the answers

    What is the purpose of the getSource() method of the EventObject class?

    <p>To return the Object involved in the event</p> Signup and view all the answers

    What does the getStateChange() method of the ItemEvent class return?

    <p>An integer named ItemEvent.SELECTED or ItemEvent.DESELECTED</p> Signup and view all the answers

    Which listener interface has methods named focusGained() and focusLost()?

    <p>FocusListener</p> Signup and view all the answers

    Which event type is generated when a button in a Swing GUI is clicked?

    <p>ActionEvent</p> Signup and view all the answers

    What is the parent class of all event objects in Java?

    <p>EventObject</p> Signup and view all the answers

    Which event listener is used to handle events generated from scroll bar movements?

    <p>AdjustmentListener</p> Signup and view all the answers

    What method gets executed in response to the generated events in an event listener object?

    <p>responseMethod</p> Signup and view all the answers

    Which event type is generated when text is entered into a text field in a Swing GUI?

    <p>ActionEvent</p> Signup and view all the answers

    Which event listener is used to handle events generated from text field gaining or losing focus?

    <p>FocusListener</p> Signup and view all the answers

    Use Quizgecko on...
    Browser
    Browser