We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Set hour glass

mattjulius
mattjulius asked
on
Medium Priority
483 Views
Last Modified: 2011-09-20
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.
Comment
Watch Question

zzynxSr. Software engineer
CERTIFIED EXPERT

Commented:
zzynxSr. Software engineer
CERTIFIED EXPERT

Commented:
In your case: use Cursor.WAIT_CURSOR
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
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

Author

Commented:
to zzynx:

I already have that but how can I do it while in process.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
You need to call on the event disspatch thread

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

zzynxSr. Software engineer
CERTIFIED EXPERT

Commented:
>> 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);
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
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);
       }
    });
}

Sr. Software engineer
CERTIFIED EXPERT
Commented:

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
zzynxSr. Software engineer
CERTIFIED EXPERT

Commented:
Thanx 4 axxepting
What answer did you expect to award it with an A grade?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.