29 Questions
0 Views
3.7 Stars

OOPR212 Java Event Handling: Inheritance Hierarchy Quiz

Test your knowledge on the inheritance hierarchy of event classes in Java, focusing on Swing GUI events and event handling. Learn about how events represent user interactions with the application and the parent classes such as EventObject and AWTEvent.

Created by
@WieldyParadise5827
1/29
Find out if you were right!
Create an account to continue playing and access all the benefits such as generating your own quizzes, flashcards and much more!
Quiz Team

Access to a Library of 520,000+ Quizzes & Flashcards

Explore diverse subjects like math, history, science, literature and more in our expanding catalog.

Questions and Answers

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

int getClickCount

Which MouseEvent event method provides the x-position of the event relative to the source component?

getX()

In the JList Class, what is used to construct a JList object?

An array of Strings

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

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team
Use Quizgecko on...
Browser
Browser