Our example is a JFrame Window which can display a Context Menu. A context menu will appear at the click location of the mouse when user right clicks anywhere in the form except the title bar. The displayed menu will not have any title and it contains three menu items in it.
Tag Archive for ‘MouseListener’
A line requires two points. The JAVA AWT Graphics API also require two points to perform Line Drawing. In our Example, we will use left mouse press to record the first point and left mouse release to record the second point. Then, the Graphics API uses these two points to draw the line. This means, after pressing the mouse button, the user will drag the mouse to the location where they want the second point. Once the second point location is reached, the user will release the mouse button. The below picture explains the sequence of operation on the mouse to draw a line:
In 80s, usually mouse came with only two buttons. One is for left click and other one is for right click. Now as days mouse comes with three buttons and a wheel in the middle. The wheel allows scrolling the contents, and also it allows click. Below is the picture of the modern days mouse.