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

java, jlabel, mouseover, swing

Solution

You can set cursor of JLabel to Cursor.HAND_CURSOR using below code :

JLabel label = new JLabel("https://stackoverflow.com");
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

Problem

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?

Original source