Wait Cursor issue in JFrame / JButton

Hi i am Creating some Archive which takes 2 to 3 min . I had set Wait Cursor
applet.getFrame().setCursor( new Cursor(Cursor.WAIT_CURSOR));
but after i Click Button (which shows Hand Cursor during Click) after that my wait Cursor is not shown.
The cursor remains as Hand Cursor??

Following Code worked for Using JRE version 1.6.0_13 Java HotSpot(TM) Client VM
But not Fixed for 1.5.x or JRE version 1.6.0_10 Java HotSpot(TM) Client VM
Issue 1:
The hand Cursor still remain as it is.
myFrame.setWaitCursor();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                          // business logic for Creating WAR (which takes around 5 min)
               }Issue 2: When it takes take to create Archive , if we toggle different window 7 come back in my Application Window it shows Blank Window (or half Desktop Window / half my APplication title Window) till it doesnt creates WAR Generation. Is there some paint Issue ??
After my War is generated I am able to view my UI

Similar Messages

  • Automatic Wait Cursor -problems

    I have implemented an automatic wait cursor "system" as decribed in Guide 1( http://www.roseindia.net/javatutorials/WaitCursorEventQueue.shtml)
    The problem I have occurs at a specific moment:
    - I have one Jframe opening another Jframe. This Jframe again (a customer registration form) displays a simple JOptionPane box. At the moment the JOptionPane box is displayed, the whole system goes down.
    At all other times the wait cursor behaves exactly as intended.
    Does anyone have:
    - any experience with this (Guide 1) implementation of automatic wait cursor?
    - any other experience with automatic wait cursors?
    Regards

    yes, i actually use a slightly modified version of that concept and it works very well...so far.
    there is a known deadlock issue with it though which has been reported on many forums.
    you can get easily around it though, without any implications as far as i can tell at least.
    I have tried to reproduce your issue, but in the situation you describe i do not get any
    problems. possibly you ran across the above deadlock problem?
    the one thing i am not so sure about is that you call set/resetCursor not within the EDT.
    however from the source of JComponent.setCursor() it looks as if the call would be done directly
    on the native peer, so in theory it could be safe to do that call from within another thread.
    Edited by: produggt on 20.08.2008 18:47

  • Wait cursor behaving strangely

    Hi ,
    I have a modal dialog, when i press ok on the modal dialog i start some operation and during this time i want the cursor to be changed to wait cursor, but though its happening okay but once i go out of the application and then come back it changes to a double arrow cursor, though the process is still not completed.

    My bad. In your ActionListener, you have to start another thread to do the work so that event dispatching thread can update screen. St glasspane visible before starting, at the end of that thread, make glasspane disappear.
    Run the following code, after the frame is displayed, click on some other application window and come back and see how it works - kill me if it doesn't
    import java.io.File;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.event.MouseInputAdapter;
    public class IconGlassPane extends JComponent {
         public static void main(String s[]) {
              JFrame frame=new JFrame();
              final IconGlassPane glass=new IconGlassPane(null);
              frame.getRootPane().setGlassPane(glass);
              Action showAction=new AbstractAction("Get Busy") {
                   public void actionPerformed(ActionEvent ae) {
                        glass.setMessage("Getting busy now");
                        glass.setVisible(true);
                        Runnable task=new Runnable() {
                             public void run() {
                                  try {
                                       glass.setMessage("Sleep for 5 seconds");
                                       Thread.currentThread().sleep(5000);
                                       glass.setMessage("First nap over. What do next?");
                                       Thread.currentThread().sleep(2000);
                                       glass.setMessage("Maybe nap for 5 more seconds");
                                       Thread.currentThread().sleep(5000);
                                  } catch (Throwable th) {
                                       th.printStackTrace();
                                  } finally {
                                       glass.setVisible(false);
                   new Thread(task).start();
              frame.getContentPane().add(new JButton(showAction), BorderLayout.SOUTH);
              frame.getContentPane().add(new JLabel("Main Content Area"));
              frame.setSize(600, 400);
              frame.setVisible(true);
         private Icon icon;
         private String message;
         private transient Cursor busyCursor;
         private transient Cursor normalCursor;
         public void setVisible(boolean b) {
              super.setVisible(b);
              if (b) setBusyCursor();
              else setNormalCursor();
         public IconGlassPane(Icon icon) {
              //if (icon==null) icon=new ImageIcon();
              //throw new NullPointerException();
              this.icon=icon;
              Listener l=new Listener();
              addMouseListener(l);
              addMouseMotionListener(l);
              busyCursor=Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
              setCursor(busyCursor);
              normalCursor=Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
         public void paint(java.awt.Graphics g) {
              int width=100;
              int height=100;
              if (icon!=null) {
                   width=icon.getIconWidth();
                   height=icon.getIconHeight();
              Dimension dim=getSize();
              int x=(dim.width-width)/2;
              int y=(dim.height-height-10)/2;
              if (x<0) x=0;
              if (y<0) y=0;
              if (icon!=null) icon.paintIcon(this, g, x, y);
              if (message==null) return;
              y+=(height+12);
              try {
                   Font f=getFont();
                   setFont(f.deriveFont(f.BOLD|f.ITALIC, 16.0f));
              } catch (Exception e) {
              g.drawString(message, x, y);
         public void setMessage(String message) {
              this.message=message;
              repaint();
         public void setBusyCursor() {
              setCursor(busyCursor);
         public void setNormalCursor() {          setCursor(normalCursor);     }
         class Listener extends MouseInputAdapter {
              public Listener() {}
              public void mouseMoved(MouseEvent e) {
                   redispatchMouseEvent(e, false);          }
         public void mouseDragged(MouseEvent e) {
              redispatchMouseEvent(e, false);
              }          public void mouseClicked(MouseEvent e) {
                   redispatchMouseEvent(e, false);          }
                   public void mouseEntered(MouseEvent e) {
                        redispatchMouseEvent(e, true);          }
                        public void mouseExited(MouseEvent e) {
                             redispatchMouseEvent(e, false);          }
                             public void mousePressed(MouseEvent e) {
                                  redispatchMouseEvent(e, false);          }
                                  public void mouseReleased(MouseEvent e) {
                                       redispatchMouseEvent(e, true);          }
                                       private void redispatchMouseEvent(MouseEvent e,
                                       boolean repaint) {
                                            if (repaint) {
                                                 repaint();
                                            }     }}

  • Wait cursor shows up as a resize cursor in certain situations

    Strange behavior and my question are below in the comments. I intend to test this program on JRE 1.6 when I get a chance.
    package project2;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.Rectangle;
    import java.awt.event.ActionEvent;
    import javax.swing.AbstractAction;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    // It looks like I found a bug in JRE 1.5
    // The program below shows a main frame in the top left of the screen
    // Press the Dialog button to bring up a dialog box.
    // Upon closing the dialog box,
    // the program will install a wait cursor on the main frame,
    // wait 5 seconds, print some text to standard output,
    // and finally restore the cursor.
    // Run the program.  Call up the dialog box.
    // Move the dialog box to outside the main frame --
    // that is, no parts of the dialog box and main frame should overlap.
    // Close the dialog box.  Right away move the cursor over the main frame.
    // Notice that the cursor is not an hourglass,
    // but rather a resize cursor.
    // Now shutdown the program and run it again.  Call up the dialog box.
    // Move the dialog box to inside the main frame.
    // Upon pressing OK or Cancel, we do see the wait cursor for 5 seconds.
    // If we call up the dialog box again and move outside the main frame,
    // then upon closing the dialog box the hourglass appears.
    // However, if we shutdown and restart then the resize cursor appears.
    // Why do we only see the hourglass when the dialog box is
    // inside the main frame?
    public class MyFrameDisposeDialogFirst extends JFrame
       private JButton jButton1 = new JButton();
       public MyFrameDisposeDialogFirst()
          try
             jbInit();
          catch (Exception e)
             e.printStackTrace();
       private void jbInit() throws Exception
          this.getContentPane().setLayout(null);
          this.setSize(new Dimension(400, 300));
          jButton1.setBounds(new Rectangle(80, 60, 73, 22));
          this.getContentPane().add(jButton1, null);
          jButton1.setAction(new AbstractAction("Dialog") {
             public void actionPerformed(ActionEvent event)
                try
                   String[] choices = new String[] { "One", "Two", "Three", "Four" };
                   Object result = JOptionPane.showInputDialog(MyFrameDisposeDialogFirst.this, "Username", "Title", JOptionPane.QUESTION_MESSAGE, null, choices, choices[1]);
                   MyFrameDisposeDialogFirst.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   try
                      Thread.sleep(5000);
                   catch (InterruptedException e)
                   System.out.println(result);
                finally
                   MyFrameDisposeDialogFirst.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
       public static void main(String[] args)
          JFrame frame = new MyFrameDisposeDialogFirst();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
    }

    It's the old story of not respecting the EDT and [Concurrency in Swing|http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html]. Try this (could be better but I tried to keep the changes to a minimum):import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.Rectangle;
    import java.awt.event.ActionEvent;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.SwingUtilities;
    import javax.swing.Timer;
    public class MyFrameDisposeDialogFirst extends JFrame
       private JButton jButton1 = new JButton();
       private Action action = new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
             MyFrameDisposeDialogFirst.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
       private Timer timer = new Timer(5000, action);
       public MyFrameDisposeDialogFirst()
          jbInit();
       private void jbInit()
          this.getContentPane().setLayout(null);
          this.setSize(new Dimension(400, 300));
          jButton1.setBounds(new Rectangle(80, 60, 73, 22));
          this.getContentPane().add(jButton1, null);
          timer.setRepeats(false);
          jButton1.setAction(new AbstractAction("Dialog") {
             public void actionPerformed(ActionEvent event)
                String[] choices = new String[] { "One", "Two", "Three", "Four" };
                Object result = JOptionPane.showInputDialog(MyFrameDisposeDialogFirst.this, "Username",
                      "Title",JOptionPane.QUESTION_MESSAGE, null, choices, choices[1]);
                SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                      MyFrameDisposeDialogFirst.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                      timer.start();
                System.out.println(result);
       public static void main(String[] args)
          final JFrame frame = new MyFrameDisposeDialogFirst();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                frame.setVisible(true);
    }db

  • Constant wait cursor when editing with LVOOP

    I've searched around several times for any mention of this problem but have never found anything. It continues to drive me crazy so I figure I'd ask about it.
    I have a decently sized project utilizing about 25 LVOOP classes in the hierarchy. Whenever I edit a VI within a class, every change I make causes a wait cursor for about a second or 2. This is not a long time, but when I'm in the middle of making something and trying to edit a VI rapidly, it gets extremely annoying to be blocked every couple seconds as I place, move, and wire objects.
    I assume this has to do with compiling the VI, any callers, and doing something with the class, but is it common to block input while this takes place? Is there any remedy for this?
    I'm developing on a 1 yr old Xeon system with a 10k rpm drive and 12GB of ram, it's definitely not an issue with my computer being slow.
    Thanks

    I am working on a large LVOOP project with 30 lvclasses.  The only time I get the wait cursor is when I edit the type defs and select Apply Changes. I do not notice any delays when editing the VI's whether they are methods or plain old utilities. 
    In my hierarchy, I created inheritance by having lvlibs which also contain lvclasses.  Most methods now access the superclass (well, that's what I call it..  the cluster that contains all classes).
    Do you have access to another PC which has LV installed?  If so, do you get the same behavior?

  • Messages will open nothing appears(with wait cursor)

    Since I upgraded to Mavericks, everytime i open Messages, it opens, and the top bar becomes Message settings but nothing appears and the wait cursor keeps turning forever so I have to force quit.
    I have tried opening it from the applications folder and resetting keychain as i read in other threads but it still doesnt work.
    I still get message notifications and the badge appears when i have a message. And the app and accounts are all working on my iphone.
    I keep sending error report to apple every time i force quit but it seems not enough people have this issue...
    Please help, it's bugging me so much.
    Thank you.

    Hi,
    Sending the reports is a silent thing and it may in fact be several Updates before anything makes it way to an update.
    I would check two things first.
    1) Open the Font Book from the Applications folder.
    Top left set it to All Fonts if it is not already
    Then use the Edit Menu > Look for Enabled Duplicates.
    Follow this by checking the Helvetica and Lucida Grande are active (Some App will not launch if Helvetica is Off and Lucida Grande is used to display Buddy lists when they have groups active  - you need the font before you open the app).
    2) Open the Contacts App.
    Use the Card Menu > Go to My Card
    This should be your Card and show your details.
    It should be marked with the Head and Shoulders icon.
    If it is neither of these can you post the Log you are sending to Apple ?
    If it is a Crash Log it may pay too be selective about how much you post.
    We need to see the OS version number info at the top and the app info under that.
    The info about the fault and the thread that crashed and those threads will help.
    The Binary Images bit can be very long.
    Limit this to the first 10 lines or so.
    Messages and the Address Book  should be listed near the top as involved items that have just been used by the app's processes.
    8:52 pm      Saturday; March 29, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Win32 SetCursor from other thread (Wait Cursor)

    As soon as my application starts to decode a bitmap, i need to update two static text labels to show current progress. Updating them for every decoded pixel would be too overkill so I decided to make every update inside a timer every 150ms.
    This obviously implies the use of a worker thread that leaves the main UI thread able to process WM_TIMER messages thus updating these two textlabels, and invalidate the possibility of just surrounding my work code in two SetCursor functions.
    I googled a bit and found that handling WM_SETCURSOR could do the trick, and so I tested it this way :
    case WM_SETCURSOR:
    if (DecodingThreadRunning) SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT)));
    else SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
    break;
    Somehow the call gets executed with no errors but the cursor remain the same.
    I also tried to surrond the working thread with the AttachThreadInput function but still no luck :
    HWND hWnd = GetForegroundWindow();
    DWORD foregroundThreadID = GetWindowThreadProcessId(hWnd, 0);
    DWORD currentThreadID = GetCurrentThreadId();
    AttachThreadInput(foregroundThreadID, currentThreadID, TRUE);
    SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT)));
    //Do the work
    AttachThreadInput(foregroundThreadID, currentThreadID, FALSE);
    Honestly I feel lost since i'm not even sure that the IDC_WAIT cursor was supposed to be used in this case, since the main GUI remains actually usable and stable (although few option gets disabled)
    Thanks in advance for any help
    PS: Running an update every nth pixel would not be as stable and fancy looking as the more accurate update of a timer
    PPS: That's it I'm a retard.    I forgot to return TRUE from WM_SETCURSOR.
    I'll change the core of the question then : is the wait cursor supposed to be used in this case ? why attachthreadinput does not work ? Does it needs the thread to have a message queue ?

    Somehow the call gets executed with no errors but the cursor remain the same.
    Set a breakpointer to check if SetCursor method is reached.
    if (DecodingThreadRunning)
    And how do you determine your thread is running? Do you use WaitForSingleObject method? We need some more information to reproduce this issue.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Toshiba Laptop - cursor issues

    Hello - I have a Toshiba C55D-A5120, serial # XXXXXXXXX. The issue began today: I open the laptop, enter my PIN, the screen opens normally, but the cursor freezes. I have to exit via the Task Manager. This is the first problem I have incurred.
    Thank you for your time and help. --- Chrisanne
    [Moderator edit to remove serial number.]

    Hi Chrissane!
                  I have read some posts about cursor issues. You can try doing a power cycle by removing all power by removing everything connected to the laptop then turn it on pressing F2 immediately and it goes to a setup screen where you can hit defaults by pressing f9 then enter and f10 to save and exit. after it restarts, log in with your pin then once you have your desktop back, press f5 only once then wait for atleast 30 seconds and try your cursor to see if its works already. Hope this helps! Have a great weekend!

  • Set wait Cursor allows cursor to Clicon on Button ?

    Sometimes when i set my cursor to wait cursor still it allows me to click on Components Like JButton or Tree node 7 sometime it works perfectly (it doesn't allow to click which i am expecting)

    I can assure you that it has nothing to do with you setting the wait cursor; you are only setting the graphic, it doesn't change the way your application behaves on mouse clicks. More likely is that "sometimes":
    1) your application is doing a lot of work
    2) it is doing this work on the Swing EDT
    3) and such your application is unresponsive, giving you the idea that you cannot click buttons
    If you want to prevent users from clicking buttons, you need to disable the buttons while you are doing whatever it is you are currently setting the wait cursor for.

  • Changing wait cursor in netbeans.

    Hi,
    I'm having problems trying to change my cursor, I'm using netbeans and i want to change the cursor when a task is been doing.
    I have a frameview and will show you the code. But i'm getting a error using setCursor().
    I tried using a Jframe instead of a FrameView and this code works ok. Who knows why i can't use setCursor() with a FrameView?
    Thanks for your help
    public class ProgressBarDemo extends FrameView
    private Task task;
    class Task extends SwingWorker<Void, Void> {
    @Override
    public Void doInBackground() {
    Random random = new Random();
    int progress = 0;
    //Initialize progress property.
    setProgress(0);
    while (progress < 100) {
    //Sleep for up to one second.
    try {
    Thread.sleep(random.nextInt(1000));
    } catch (InterruptedException ignore) {}
    //Make random progress.
    progress += random.nextInt(10);
    setProgress(Math.min(progress, 100));
    return null;
    @Override
    public void done() {
    Toolkit.getDefaultToolkit().beep();
    startButton.setEnabled(true);
    setCursor(null); //turn off the wait cursor
    taskOutput.append("Done!\n");
    /** Creates new form ProgressBarDemo */
    public ProgressBarDemo() {
    initComponents();
    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {
    startButton.setEnabled(false);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    //Instances of javax.swing.SwingWorker are not reusuable, so
    //we create new instances as needed.
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new ProgressBarDemo().setVisible(true);
    }

    So, you are talking about Swing application Framework???
    It would certainly not work because 'FrameView' is neither a Frame, nor a Panel, etc. , I don't think NetBeans would allow you to compile such a code.
    See you can use:
    there is an '.........App' class,( for your case it may be ProgressBarDemoApp, but I doubt it), use its static method to obtain refrence to mainframe like this:
    JFrame frm= ProgressBarDemoApp.getApplication().getMainFrame();
    frm.setCursor(Cursor.WAIT_CURSOR);Another possibility is:
    NetBeans make a default main panel in View named 'mainPanel', you can set its default cursor:
    mainPanel.setCursor(Cursor.WAIT_CURSOR);hope it works............
    Thanks!

  • Spinning wait cursor

    For the past month or so I have been experiencing the wait cursor more and more to the point where it now shows up every 10-15 seconds. This mostly results in my chrome browser to crash and sometimes even completely locking up and forcing me to hold the power button to restart.  I have searched for solutions and nothing has shown to work. My hard drive still has 170 GB available so that isn't the issue.  I have updated norton antivirus that shows no viruses.  I have cleared all my caches and repaired all disk permissions.  I have also updated my OS to lion. I'm not the most computer savvy person but obviously something is conflicting to cause the massive slow down.
    These episodes occur one to two times a day where my MacBook pro is almost unusable.  I brought it in to my college tech service and all they did was open up 10 or so applications and called it okay.
    Anything else that's worth trying? Is there any free diagnostic software that will at least show me what the problem is?

    25 ways to speed up your mac: http://www.maclife.com/awordfromoursponsors?destination=article%2Ffeature%2F25_w ays_speed_your_mac
    troubleshoot the spinning beachball: http://www.macworld.com/article/151583/2010/05/spinningbeachballofdeath.html
    you can also download OmniDiscSweeper to se the largest files on your mac: http://download.cnet.com/OmniDiskSweeper/3000-18512_4-6226.html

  • Endless wait cursor

    Lion is horrible. I experience constant wait cursors in mail, browsers and finder. I have been through every level of tech support and am an experienced user. The bottom line is that I regret ever "upgrading" to Lion. Snow Leopard was rock solid, now I am stuck with a bloated dog with useless features and total instability. The very worst of these new features is resume. An absolute albatross.

    A little of both perhpas. I have done everything you suggested, all of which is standrd install protocol, multiple times. The (several) clean installs were on a completely reformatted disk and I have gone through the whole indexing thing. That was an intital issue but is no longer the problem as indicated by the lack of indexing activity before and during the wait cursor period. The wait cursor problem is widespread. I have read about in many forums and have first hand experience with fellow Mac users trying to help solve the problem. There has been very little ascknowledgment of this by Apple. I was just talking to a friend today who bought a brand new Mac and, long after the initial indexing period, continued to experience long wait cursor moments, by which I mean up to 30 or more minutes. I have filed several bug reports related to this and have included system profiles, crash logs, start-up logs and "sudo sysdiagnose" terminal reports. So, yes, I am venting, and yes, I do have a question: when will this problem be fixed? I would also like to acknowledge that I know Lion is working quite well for many if not most people. I have it installed on another computer and have had only a few wait cursor instances. Still, it is widely reported and needs to be addressed. Once it is fixed, there also needs to be ways of turning off features like resume and auto save, restoring the functionality of save as, etc. Some people may find those things useful, but many do not and they should have the option to turn them off without having to resort to compex command line chemistry.

  • Wait Cursor not showing while moving the Mouse

    I have a JFrame application. In that JFrame i have a Jdialog (login screen). After entering user name and password, i am setting the Wait cursor (hour glass) for the JFrame and JDialog. When the mouse cursor is inside dialog, it is properly showing the wait cursor. I can able to move the mouse within dialog.
    But When I move the mouse outside the dialog i.e inside JFrame, the wait cursor goes off. It shows default cursor. Even I have set the wait cursor to JFrame.
    What may be the problems? If any body knows, please expaling.
    Advance thanks for early reply.

    if any knows the solution, please post it.

  • Wait cursor not working with short cut keys

    Hi,
    I have JButton in my application for which i have set the short cut key using
    button.setMnemonic(char)
    method of JButton. Also i have set the wait cursor for the same button using
    button.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)) .
    I am getting the wait cursor if i click on the button,but not when i use the shortcut key.
    Why is it like that? Pls help me out.

    Why don't you use this class :
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.SwingUtilities;
    public class WaitCursorEventQueue extends EventQueue {
    public WaitCursorEventQueue(int delay) {
    this.delay = delay;
    waitTimer = new WaitCursorTimer();
    waitTimer.setDaemon(true);
    waitTimer.start();
    protected void dispatchEvent(AWTEvent event) {
    waitTimer.startTimer(event.getSource());
    try {
    super.dispatchEvent(event);
    finally {
    waitTimer.stopTimer();
    private int delay;
    private WaitCursorTimer waitTimer;
    private class WaitCursorTimer extends Thread {
    synchronized void startTimer(Object source) {
    this.source = source;
    notify();
    synchronized void stopTimer() {
    if (parent == null)
    interrupt();
    else {
    parent.setCursor(null);
    parent = null;
    public synchronized void run() {
    while (true) {
    try {
    //wait for notification from startTimer()
    wait();
    //wait for event processing to reach the threshold, or
    //interruption from stopTimer()
    wait(delay);
    if (source instanceof Component)
    parent = SwingUtilities.getRoot((Component)source);
    else if (source instanceof MenuComponent) {
    MenuContainer mParent =
    ((MenuComponent)source).getParent();
    if (mParent instanceof Component)
    parent = SwingUtilities.getRoot(
    (Component)mParent);
    if (parent != null && parent.isShowing())
    parent.setCursor(
    Cursor.getPredefinedCursor(
    Cursor.WAIT_CURSOR));
    catch (InterruptedException ie) { }
    private Object source;
    private Component parent;
    and then add to your application :
    //Wait cursor
    EventQueue waitQueue = new WaitCursorEventQueue(200);
    Toolkit.getDefaultToolkit().getSystemEventQueue().push(waitQueue);
    The number (200) specifies the milliseconds to activate the WaitCursor.
    It will work anytime your app is busy for more than that time.

  • Wait cursor appears only the first time... unless I don't move the mouse!

    Ah yes, another cursor problem:
    I am setting a wait cursor in my main JFrame when a key-release or a menu item click is detected (the time-consuming action is then triggered in a child JInternalFrame), and so far, it's been working great.
    Then I noticed that the wait cursor only appears the first time the time-consuming action is called (or more precisely, if I never move the mouse, it happens every time as it should, but if I move the mouse, it only happens the first time! Ah, and I noticed I CAN move the mouse but ONLY when it is in the form of the wait cursor!).
    Strangely, I can see the cursor blink briefly when the action is done, precisely when it should be changing back to the default cursor... what gives? If I close the child internal frame and re-open it, I can get the wait cursor again the first time only (again, unless I keep the mouse still, in which case it works great - argh).
    Any ideas would be deeply appreciated!
    Cheers!
    PS - Here's a snippet of how we set the cursor, this is code in our main JFrame, called via either a keypress event or clicking on a menu item - mostly it's stuff that is unrelated, and we simply set the wait cursor as the very first line, so why in the world would it skip that line???? (the rest of the lines do in fact get executed):
    private void refreshMenuItemActionPerformed(java.awt.event.ActionEvent evt) {     doRefreshMenuItemAction(); }
    private void doRefreshMenuItemAction() {
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    JDesktopPane desktop = (JDesktopPane)this.getContentPane().getComponent(0);
    JInternalFrame activeFrame = desktop.getSelectedFrame();
    try {
    if ( activeFrame instanceof IDataDrivenForm ) {
    ((IDataDrivenForm)activeFrame).refresh();
    } catch (Exception ex) {
    ex.printStackTrace();
    this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

    almost...
    I now see that glasspanes are an answer to that question. I got it to work (almost) using a glasspane (see code snippet below). But what I can't quite grasp now is why this code does not work when I call it from a child (contained) dialog (and possibly internal frames as well)??? When I do so, the dialog freezes (the button I pressed doesn't even release) and the cursor does not change to waiting. This time I'm really not sure where to go next....
    I appreciate anyone who has read this far, and would really be indebted to you for some good advice!
    PS - Here's the nifty code, placed in my main JFrame class. I just substituted "this.setBusy(true);" for every place I was manually setting the WAIT_CURSOR in the past (and of course with matching setBusy(false)):
    public final void setBusy(boolean isBusy)
    Component glassPane = this.getGlassPane();
    Cursor theCursor = isBusy ? Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) : Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR );
    this.setCursor( theCursor );
    glassPane.setCursor( theCursor );
    glassPane.setVisible( isBusy );

Maybe you are looking for

  • In eRecruitment - Application wizard F4 Values are not getting displayed.

    Hi, I have created a seperate process template for MBA candidates (external) as per client requirement and in the Vacancy req.when the process template is selected the application wizard is getting displayed ( which has been defined according to new

  • Af:tree Master child relation ,but showing child id's as parent node vice

    Hi , Am using adf 11G 11.1.1.5 I have a small requiement . Am using af:tree , where i display childId's . Onclick of child it i have to show popup with tree structure where i will show parentid as node and childId's as child nodes i have created view

  • Good way of coding?

    Hi guys, Im working on my first website in flash and i was wondering if i code in a good way. I dont have experience with flash websites at all only animation. So i thought im in for a greater project like my own website in flash because its now php.

  • When im creating PO using MIGO

    Hi,Gurus.. When im creating PO using MIGO . im getting error Document number 6000000455 not within defined interval. can any one help me.. thnx in advace.

  • Vlan IP address

    Hi I have setup on a catalyst 2900 serie 2 vlan. The default vlan with ID 1 and a ip address setup. I can ping this vlan interface from all my private network. I setup an ip address on the vlan ID 2 (in its network range) ... but I can not ping this