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() (A)</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 (C)</p> Signup and view all the answers

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

<p>getMaxSelectionIndex() (D)</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 (B)</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() (A)</p> Signup and view all the answers

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

<p>True (C)</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() (A)</p> Signup and view all the answers

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

<p>Index of the first visible cell (B)</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) (B)</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) (B)</p> Signup and view all the answers

Which static int of MouseEvent class indicates no mouse buttons?

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

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

<p>MouseInputListener (A)</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) (B)</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) (D)</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 (B)</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 (C)</p> Signup and view all the answers

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

<p>MouseMotionListener (D)</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 (B)</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 (A)</p> Signup and view all the answers

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

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

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

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

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

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

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

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

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

<p>responseMethod (A)</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 (C)</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 (C)</p> Signup and view all the answers
Use Quizgecko on...
Browser
Browser