Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wait cursor

 
Sabina Norderhaug
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have wait cursor set in action_Performed as:
mLoginDialog.startWaitCursor(mLoginDialog.getRootPane());
where

/** Sets cursor for specified component to Wait cursor */
public static void startWaitCursor(JComponent component) {
RootPaneContainer root =
(RootPaneContainer)component.getTopLevelAncestor();
root.getGlassPane().setCursor(WAIT_CURSOR);
root.getGlassPane().setVisible(true);
}
/** Sets cursor for specified component to normal cursor */
public static void stopWaitCursor(JComponent component) {
RootPaneContainer root =
(RootPaneContainer)component.getTopLevelAncestor();
root.getGlassPane().setCursor(DEFAULT_CURSOR);
root.getGlassPane().setVisible(false);
}

When I click the button, I see default wait cursor (sandglass) no probelm. But if I move mouse outside this frame and then move it back, cursor changes to one of the resize cursor, so it looks like either horizontal or vertical 2 point arrow.
I wonder why this is happening and how can I avoid it?
Thank you,
Sabina
 
Mary Taylor
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question was passed to the Swing/AWT forum where it was closed because the question already existed in this forum. Circle with no answers. Not very helpful. The bartender in the forum the message was passed to closed the message because it was a duplicate of the message that was passed to that forum. How about an answer?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, this code works fine... the actual problem is that the event thread is being blocked in some way, which keeps the cursor from changing back to what it's supposed to be after the native frame changes it to the resize cursor. Try the code below, then comment out the new thread being launched in the ActionListener (and leave the contents of the run() inside the actionPerformed()) and you will see the same behavior.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic