B4J Question How to change mouse cursor while program is busy [solved]

Discussion in 'B4J Questions' started by Didier9, Jun 26, 2019.

  1. Didier9

    Didier9 Active Member Licensed User

    Some tasks take a while and I would like to change the cursor to the hourglass cursor so the user knows something is going on.
    Not sure how to do that.
    TIA
     
  2. DonManfred

    DonManfred Expert Licensed User

    Cableguy likes this.
  3. Didier9

    Didier9 Active Member Licensed User

    Thank you Don, I think it is getting close, but in the context of the proposed code:

    Code:
    Dim cursor As JavaObject
    cursor.InitializeStatic("javafx.scene.Cursor")   

    Dim joObj as JavaObject = ap
    joObj.RunMethod(
    "setCursor"Array(cursor.GetField("E_RESIZE")))
    what is "ap"?

    PS: I did use Search but probably did not use the proper keywords and did not see that post...
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    MainForm.RootPane.MouseCursor = fx.Cursors.WAIT
     
    MarkusR, Didier9 and giannimaione like this.
  5. Didier9

    Didier9 Active Member Licensed User

    Thank you Erel, that was too easy :(
     
  6. Didier9

    Didier9 Active Member Licensed User

    Turns out it is working but not necessarily as you would expect.
    If the cursor is changed and changed back to default within a function block, the cursor on screen will not actually change. Simply inserting Sleep(0) after the first command did not seem enough to allow java to actually change the cursor but maybe because the delay between the two commands is too short at the moment.

    Is there another way to force the screen to be redrawn with the new cursor?

    PS: I changed the Sleep(0) to Sleep(500) and definitely the cursor changes :) I call this victory!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice