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

[macos] cursor changes stop working after two setCursor() calls

XMLWordPrintable

    • x86_64
    • os_x

      ADDITIONAL SYSTEM INFORMATION :
      macOS 12.0.1 with either Java 17, 16, or 12 - all JDKs I've tried have the same issue.

      A DESCRIPTION OF THE PROBLEM :
      I change the cursor via Component.setCursor() to a "busy" cursor and it works fine. When the long-running activity is done, I change it back to a normal one. That works fine too. But in macOS 12 (Monterey), when I subsequently change it to "busy" again, the cursor does not change. The same code works fine in Windows 10 and Ubuntu 20.04.

      I also asked around in the Netbeans forum and a couple guys tried the same code in macOS Catalina (10.15) and in Big Sur (11) w. JDK 15 and they had no problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the source code below.
      1) Push the "Busy" button. Cursor change to "busy".
      2) Push the "Normal" button. Cursor changes back to a normal cursor.
      3) Push the "Busy" button a second time - nothing happens.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected the cursor to change to "Busy" again.
      ACTUAL -
      Cursor stays normal.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.Container;
      import java.awt.Cursor;
      import java.awt.event.ActionEvent;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.SwingUtilities;

      public class BugTest {
      public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
      final JFrame f = new JFrame();
      f.setSize(400, 400);
      f.setLocationRelativeTo(null);
      Container c = f.getContentPane();
      JPanel p = new JPanel(new BorderLayout());
      c.add(p);
      JButton b1 = new JButton("Busy");
      b1.addActionListener((ActionEvent e) -> {
      f.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      });
      JButton b2 = new JButton("Normal");
      b2.addActionListener((ActionEvent e) -> {
      f.getGlassPane().setCursor(Cursor.getDefaultCursor());
      });
      p.add(b1, BorderLayout.NORTH);
      p.add(b2, BorderLayout.SOUTH);
      f.setVisible(true);
      f.getGlassPane().setVisible(true);
      }
      });
      }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      There is no workaround.

      FREQUENCY : always


            kizune Alexander Zuev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: