Mouse Multiple Clicks getClickCount()

Mouse Multiple Clicks getClickCount()

getClickCount() of MouseEvent class returns the number of clicks done on mouse.

Following is the method signature as defined in class java.awt.event.MouseEvent

  • public int getClickCount(): Returns the number of mouse clicks associated with this event.
Mouse Multiple Clicks getClickCount() program uses getClickCount() to know the number of clicks done on the button.

Mouse Multiple Clicks getClickCount()
Output screen of Mouse Multiple Clicks getClickCount() /center>

A switch statement is preferred to display the number clicks performed by mouse.

Also know about mouse right click and double click.

View All for Java Differences on 90 Topics

2 thoughts on “Mouse Multiple Clicks getClickCount()

  1. Dave

    Unless I’ve misinterpreted the intent, there is a problem…

    A double click is reported as BOTH of the following:
    It is single click
    It is double click

    And a triple click is reported as ALL of the following:
    It is single click
    It is double click
    It is triple click

    Surely the objective should be to distinguish among the three distinct possibilities, reporting:

    – a single click
    – a double click
    – a triple click

    Anything short of that is a pretty useless example of getClickCount().

Leave a Reply

Your email address will not be published. Required fields are marked *