JDK-4320939 : WaitCursor-problems in JDK1.3RC1
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-03-13
  • Updated: 2000-07-11
  • Resolved: 2000-07-11
Related Reports
Relates :  
Description

Name: krT82822			Date: 03/12/2000


12 Mar 2000, eval1127@eng -- shares some aspects with other bugs, incl. # 4297005, but not a clear duplicate of any particular bug.

java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)

Although apparently rewritten for RC1 (there is a new class
sun.awt.GlobalCursorManager) mouse-cursor-handling still has some nasty
problems:

- when changing the mouse-cursor of a JFrame to WAIT_CURSOR, while the cursor
  is above a component which has a mouse-cursor set, the mouse-cursor will not
  change visually
- when moving the (successfully changed to WAIT_CURSOR) mouse-cursor outside of
  a JFrame (or to the title-bar or Frame-borders) and back into the JFrame, the
  cursor will be reset

You can use the following program to reproduce these problems:

-------------------- BEGIN
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class WaitCursorTest
{
    private static MouseListener listener = new MouseAdapter(){};
    
    public static void main(String Ps_args[])
    {
        final JFrame F_frame = new JFrame();
        F_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        F_frame.getContentPane().setLayout(new FlowLayout());

        JButton F_button = new JButton("1 setCursor");
        F_button.setMnemonic('1');
        F_button.addActionListener(new ActionListener(){
            JFrame frame = F_frame;
            public void actionPerformed(ActionEvent e)
            {
                frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                try
                {
                  Thread.sleep(2000);
                }
                catch (Exception ex)
                {
                }

                frame.setCursor(Cursor.getPredefinedCursor
(Cursor.DEFAULT_CURSOR));
            }
        });
        F_frame.getContentPane().add(F_button);

        F_button = new JButton("2 GlassPane");
        F_button.setMnemonic('2');
        F_button.addActionListener(new ActionListener(){
            JFrame frame = F_frame;
            public void actionPerformed(ActionEvent e)
            {
                JComponent F_gp = (JComponent) frame.getGlassPane();
                F_gp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                F_gp.setVisible(true);
                frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                F_gp.addMouseListener(listener);

                try
                {
                  Thread.sleep(2000);
                }
                catch (Exception ex)
                {
                }

                F_gp.removeMouseListener(listener);
                frame.setCursor(Cursor.getPredefinedCursor
(Cursor.DEFAULT_CURSOR));
                F_gp.setCursor(Cursor.getPredefinedCursor
(Cursor.DEFAULT_CURSOR));
                F_gp.setVisible(false);
            }
        });
        F_frame.getContentPane().add(F_button);

        JTextField F_tf = new JTextField("eins");
        F_frame.getContentPane().add(F_tf);

        F_tf = new JTextField("zwei");
        F_tf.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
        F_frame.getContentPane().add(F_tf);

        F_frame.pack();
        F_frame.setVisible(true);
    }
}
-------------------- END

This program displays a JFrame containing 2 JButtons and 2 JTextFields. The
first button uses JFrame.setCursor() to set the mouse-cursor to WAIT_CURSOR,
waits 2 seconds, then resets the mouse-cursor to DEFAULT_CURSOR. The second
button basically does the same, but using the "GlassPane-method" for changing
the mouse-cursor instead (I found this method described here in the JDC some
time ago).

  To reproduce problem 1:
- move the mouse-cursor to one of the JTextFields (mouse-cursor changes to
  TEXT_CURSOR and CROSSHAIR_CURSOR respectively)
- invoke button 1 using its mnemonic (i.e. press ALT-1)

  To reproduce problem 2:
- click button 1 (mouse-cursor changes to WAIT_CURSOR)
- invoke Button 1 using its mnemonic (i.e. press ALT-1)
- move mouse-cursor outside of JFrame and back into it

I believe that these bugs should be fixed in the final JDK1.3!
(Review ID: 102192) 
======================================================================

Name: rlT66838			Date: 05/23/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java Hotspot(TM) Client VM (build 1.3.0-C, mixed mode)

The bug reported as Bug number 4320939 is NOT fixed even though that
bug was closed as not reproducible in RC2. 

The impact of this bug is that the user cannot tell when a long-running 
operation has completed if he/she moves the cursor out of the Java GUI  window and 
then brings it back . The cursor seems to get reset when it walks 
over the border and often is left as a resize cursor until the Java app restores it to its
original state. It looks very unprofessional.
(Review ID: 105230)
======================================================================

Comments
EVALUATION Problem 1 is a requested feature, see 4100819. The current cursor model does not support cursor setting on top level window such that the cursor will show on each child. Only those components that inherit cursor from top level window will show the toplevel window cursor. A workaround is to set cursor on GlassPane instead. Problem 2 is not reproducible in RC2. It might have been fixed. This bug is closed as not reproducible. xianfa.deng@Eng 2000-03-14 The bug still exists on NT with 1.4beta-b17. However, it does not exist on Solaris. eric.hawkes@eng 2000-06-09 Here is an excerpt from an email from the responsible engineer: I think that the test case for this bug is incorrect. In it, user sets wait cursor to JFrame, calls sleep() and then sets normal cursor to JFrame. This call sequence is reasonable, but it happens on EventDispatch Thread in the action handler, so GlobalCursorManager can't do anything. But if we set the cursor in a normal way, avoiding suppression of EventDispatchThread, everything works fine. Closing as Not A Bug. eric.hawkes@eng 2000-07-11
11-07-2000