Set hour glass

I have a menu item by using process in java I call another class . I want to ask how can I change the mouse pointer to hour glass until the process is not completed.
mattjuliusAsked:
Who is Participating?
 
zzynxSoftware engineerCommented:
0
 
zzynxSoftware engineerCommented:
In your case: use Cursor.WAIT_CURSOR
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
objectsCommented:
call the setCursor(Cursor.WAIT_CURSOR) method for the component you want the hourglass to appear over (ie. when the cursor is over that component.
If you want it for the whole frame then set it for the frames content pane
0
 
mattjuliusAuthor Commented:
to zzynx:

I already have that but how can I do it while in process.
0
 
objectsCommented:
You need to call on the event disspatch thread

so call it before you start your processing thread, or call it using EventQueue.invokeLater()

0
 
zzynxSoftware engineerCommented:
>> how can I do it while in process
yourComp.setCursor(Cursor.WAIT_CURSOR);

// do your call that doens't return until done

yourComp.setCursor(Cursor.DEFAULT_CURSOR);
0
 
objectsCommented:
component.setCursor(Cursor.WAIT_CURSOR);

// start your processing thread now



And in your processing thread you set it back:


public void run() {

    // do your processing here

    EventQueue.invokeLater(new Runnable() {
       public void run() {
          component.setCursor(original);
       }
    });
}

0
 
zzynxSoftware engineerCommented:
Thanx 4 axxepting
What answer did you expect to award it with an A grade?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.