Class MouseClickedEvent


public class MouseClickedEvent extends ClientEvent<MouseClickListener>
Represents a mouse click event that occurs when a user clicks on an element in the client interface.

This event captures the coordinates of the mouse pointer at the time of the click, providing information about where the user clicked within the client viewport. The event is dispatched to registered MouseClickListener instances for processing.

Features:

  • Captures client X and Y coordinates of the mouse click
  • Extends the generic client event framework
  • Integrates with the event listener pattern for handling user interactions

Usage:


 // Create a mouse click event at coordinates (100, 200)
 MouseClickedEvent event = new MouseClickedEvent(100, 200);

 // Get the click coordinates
 int x = event.getClientX(); // Returns 100
 int y = event.getClientY(); // Returns 200

 // Dispatch to a listener
 event.dispatchTo(myMouseClickListener);
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • MouseClickedEvent

      public MouseClickedEvent(int clientX, int clientY)
      Constructs a new MouseClickedEvent with the specified client coordinates.
      Parameters:
      clientX - the X coordinate of the mouse pointer relative to the client viewport
      clientY - the Y coordinate of the mouse pointer relative to the client viewport
  • Method Details

    • getClientX

      public int getClientX()
      Returns the X coordinate of the mouse pointer relative to the client viewport.
      Returns:
      the X coordinate of the click event
    • getClientY

      public int getClientY()
      Returns the Y coordinate of the mouse pointer relative to the client viewport.
      Returns:
      the Y coordinate of the click event
    • dispatchTo

      public void dispatchTo(MouseClickListener listener)
      Dispatches this event to the specified listener for processing.

      This method invokes the listener's onEvent method with this event instance, allowing the listener to handle the mouse click event.

      Specified by:
      dispatchTo in class Event<MouseClickListener>
      Parameters:
      listener - the listener to which this event should be dispatched