Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: Java Cursors

  1. #1
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default Java Cursors

    Using the setCursor() method with HAND_CURSOR seems to return a cursor that is not the cursor for the system. I am running Windows 7 and the Aero theme cursor is not what is displayed. Is there anything that can be done to show the true system cursor or am I stuck with what Java gives me?

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    The simplest way of doing this is:

    Java Code:
    setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    The cursor in question does not look anything like the Windows 7 hand cursor but rather like something from XP.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Something,

    Java Code:
    jLabel1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  7. #7
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    I set the cursor on a JLabel.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by 67726e View Post
    I set the cursor on a JLabel.

    Then it's the same as I've posted above. So it should work.

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    Quote Originally Posted by 67726e View Post
    Using the setCursor() method with HAND_CURSOR seems to return a cursor that is not the cursor for the system. I am running Windows 7 and the Aero theme cursor is not what is displayed. Is there anything that can be done to show the true system cursor or am I stuck with what Java gives me?
    What LookAndFeel are you using?

    db

  10. #10
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    My very first line of code in my main() is

    Java Code:
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  12. #12
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    Setting the cursor to the JLabel still shows the strange looking hand icon.

    If I set the cursor to WAIT_CURSOR it displays the correct system cursor. Could this be a bug?
    Last edited by 67726e; 09-26-2010 at 08:25 PM.

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  14. #14
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    There is nothing wrong with the code itself, the cursor it displays does not look like the actual system's hand cursor. It looks like the one from XP. The thing is, if I set it to WAIT_CURSOR, it displays the system's wait cursor. Could this be a bug on Java's part?

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  16. #16
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    I am on Windows 7 as I indicated above.

  17. #17
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Are you sure that, comparing to XP and Win 7, you've work around with the same cursors. Because seems to me there is nothing wrong with your code.

  18. #18
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    Perhaps it isn't actually the XP cursor (I haven't used XP in a while, or at least not doing anything that lead me to use the hand cursor).

    Anyway here is a comparison between the cursor that should be used and the cursor displayed:



    There is clearly a difference. The true cursor has a gradient and drop shadow. The cursor showed is simple white with a black outline and no drop shadow.

  19. #19
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  20. #20
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    The thing is, if I set it to the waiting cursor, it displays the Windows 7 cursor instead of an hour glass, so why would they make this any different?

Page 1 of 2 12 LastLast

Similar Threads

  1. Open Cursors exceeed...question for fellow gurus
    By AlmostAGuru in forum Advanced Java
    Replies: 2
    Last Post: 08-11-2009, 02:37 AM
  2. [SOLVED] Custom Cursors: Thick Lines
    By Paul Richards in forum Advanced Java
    Replies: 4
    Last Post: 06-03-2009, 10:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •