Here, you will learn how to change the mouse cursor in java. Changing the cursor means showing cursor in many different shapes for the different objects.
First button is "Ok" button, when the cursor goes
upon it, cursor shape changes to hand shape. If you move the mouse over
"Cancel" button, the cursor shape changes to move cursor (
In this process the following methods to be used in the program.
The add() method has been used to add the panel to the frame. The BorderLayout container has the five components such as:
WEST, EAST and CENTER.
This method is used to declaring the predefined cursor to
set for the object. This method contains the Cursor properties which indicates
the several cursors.
This method defined in the Component class. It changes the cursor icon when the cursor goes upon the particular component.
The getPredefinedCursor() method returns the cursor object to be specified in the cursor block.
Here is the code of the program :
Liked it! Share this Tutorial