How to check cursor type

120 views Asked by At

I have set my label's cursor to hand cursor in the label's properties. So now I'm going to check if my label's cursor is hand cursor then I'll do something there. I've tried to use this code to check, but if keeps falls into the false part which means my label's cursor is not hand cursor. I don't understand why.

if (lblSample.getCursor().equals(new Cursor(Cursor.HAND_CURSOR))) {
        System.out.println("True");
    }else{
        System.out.println("False");
    }
1

There are 1 answers

0
c0der On

Cursor does not override equals(), so this method is not very useful.

You can check cursor type:

if (lblSample.getCursor().getType() == Cursor.HAND_CURSOR) {
    System.out.println("True");
}else{
    System.out.println("False");
}