Lim Min Yi
Lim Min Yi

Reputation: 148

How to check cursor type

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");
    }

Upvotes: 0

Views: 127

Answers (1)

c0der
c0der

Reputation: 18792

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");
}

Upvotes: 1

Related Questions