How to change the mouse pointer to finger pointer in swing?

Viewed 33920

In html when we create a hyperlink and point over it ,then it automatically changes to a finger pointer.

So I was wondering can we achieve the same in java swings. Suppose I have a label on clicking which a new form pops-up.But I want that when the user points over the label it should change to finger pointer,showing that something will pop-up if its clicked.In this way we can differentiate that label with normal labels on the form i guess :).

But how to do something like this?

5 Answers

go to the properties of the button or the label and scroll down you will find a column of cursor you can change to hand or whatever you want

Hossein Mobasher answer is good and mine answer is very late but i just want to add up you can also use it like this below.

JLabel label = new JLabel("http://stackoverflow.com");
label.setCursor(Cursor.HAND);

It will also work i have tried it in Java 1.8

ButtonName.SetCursor(new Cursor(12)); This one works definitely!

Related