Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4372119

Disappearing of busy cursor on JDK 1.3

    Details

    • Subcomponent:
    • Resolved In Build:
      10
    • CPU:
      x86
    • OS:
      windows_nt, windows_2000, windows_xp
    • Verification:
      Verified

      Backports

        Description

        System Information
        ==================
        Product and Version : Interim JDK v1.3RC1 for UOB Bank, Singapore
        Hardware Platform : Intel Pentium II PC
        OS Version : Window NT4.0 SP 5

        Problem description
        ===================
        In our application, we turn on the busy cursor when the task takes some
        time to complete. In the current version of JDK1.3 that we are using (
        Note : a special version with 2 patches given by Sun Support), the busy
        cursor will disappear (i.e. return to normal) when user starts to move
        the mouse around, especially when the mouse is outside of the
        application frame. We observed that this seems to happen more frequently
        when the application is doing CPU intensive tasks.

        If this frame is covered by another window and bgought to front again, the busy cursor always disappears after the frame is restored. Only the cursor part is not restored correctly.

        Some people suggested to put the cursor setting thread out of the AWT thread. I have tested it but it does not solve the problem either.

        Source Code
        ===========

        import java.awt.*;
        import java.awt.event.*;
        import java.util.Date;

        public class TestCursor
        {
            static public void main(String args[])
            {
               TestCursor app = new TestCursor();
               GUI gui = new GUI(app);
            }
        }

        class RunHandler implements ActionListener
        {
            TestCursor app;
            GUI gui;

            public RunHandler(TestCursor app, GUI gui)
            {
                this.app = app;
                this.gui = gui;
            }

            public void actionPerformed(ActionEvent ae)
            {
                gui.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
                gui.setResult("Running...");
                int i=0;
                while (i<1000000)
                {
                  Date d= new Date();
                  System.out.println(i + ": " + d.toString());
                  i++;
                }
                gui.setResult("Finished.");
                gui.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
            }
        }


        class AboutBox extends Frame
        {

            class ShutdownAdapter extends WindowAdapter
            {
                public void windowClosing(WindowEvent e)
                { dispose(); }
            }

            public AboutBox()
            {
                super("About TestCursor");
                setLayout(new BorderLayout());
                setLocation(325,300);
                setSize(240,80);
                setResizable(false);
                TextArea text = new TextArea ("Testing Cursor problem.\n09 Sep 2000");
                text.setEditable(false);
                add("North",text);
                setVisible(true);
                addWindowListener(new ShutdownAdapter());
            }

        }

        class MenuHandler implements ActionListener
        {
            TestCursor app;
            GUI gui;

            public MenuHandler(TestCursor app, GUI gui)
            {
                this.app = app;
                this.gui = gui;
            }

            public void actionPerformed(ActionEvent ae)
            {
                String sCommand = ae.getActionCommand();
                if ("Exit".equals(sCommand))
                {
                    gui.dispose();
                    System.exit(0);
                }
                else if ("About TestCursor".equals(sCommand))
                {
                    AboutBox about = new AboutBox();
                    about.toFront();
                }
            }
        }

        class GUI extends Frame
        {

            TestCursor app;
            Panel statusPanel;
            TextField statusText;

            public void setResult(String value)
            {
                this.statusText = new TextField(value,20);
                this.statusText.setEditable(false);
                this.statusPanel.removeAll();
                this.statusPanel.add(statusText);
                pack();
                show();
            }

            class ShutdownAdapter extends WindowAdapter
            {
                public void windowClosing(WindowEvent e)
                { System.exit(0); }
            }


            public GUI(TestCursor app)
            {

                super ("Test Cursor");
                this.app = app;

                addWindowListener(new ShutdownAdapter());

                MenuHandler mh = new MenuHandler(app , this);
                MenuBar mBar = new MenuBar();
                setMenuBar(mBar);
                Menu menu = new Menu("File");
                mBar.add(menu);
                MenuItem menuItem = new MenuItem("Exit");
                menu.add(menuItem);
                menuItem.addActionListener(mh);

                menu = new Menu("Help");
                mBar.add(menu);
                menuItem = new MenuItem("About TestCursor");
                menu.add(menuItem);
                menuItem.addActionListener(mh);

                setLayout(new BorderLayout());
                Panel testPanel = new Panel();
                Button b;
                testPanel.setLayout(new GridLayout(1,1));
                
                statusPanel = new Panel();
                statusPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
                statusText=new TextField("",20);
                statusText.setEditable(false);
                statusPanel.add(statusText);
                add("North",statusPanel);

                RunHandler rh = new RunHandler(app, this);
                testPanel.add(b = new Button("Press to run")); b.addActionListener(rh);
                add("Center",testPanel);

                pack();
                setLocation(300,300);
                show();
            }
        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hgodugusunw Harsha Godugu (Inactive)
                  Reporter:
                  duke J. Duke (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: