Thomas,

I built a NetBeans project running on a Mac mini M1 chip running Big Sur 
version 11.6.

I followed your instructions and switched the cursor from normal to busy about 
15 times.  It behaved exactly as you would have hoped !

I am using NetBeans 12.4 and JDK16 – the default that comes with NetBeans 12.4. 
 Also have various Zulu versions if useful to test more widely.

Thus it looks to me that you have encountered a Monterey versus Java problem.

Hope this helps.

David Gradwell.

Code as executed was:

/*
* Investigation of Thomas Wolf Issue
*/
package com.gradwell.testswingcursors;

import java.awt.Container;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.event.ActionEvent;

import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;

public class TestSwingCursors
{
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);
  }
  });
}
}

From: Thomas Wolf <[email protected]>
Date: Monday, 18 October 2021 at 21:28
To: NetBeans Mailing List <[email protected]>
Subject: slightly off-topic: Can someone with BigSur or older help me out?

I previously posted about a problem I’m encountering with Java/Swing on my Mac 
- basically cursors stop switching after one switches to another cursor & back. 
 I checked this problem as far back as I had JDKs for - so this issue exists at 
least as far back as JDK 12.  The one thing I don’t know is whether it’s to do 
with the macOS I am running - Monterey.  Unfortunately, I don’t have a machine 
with BigSur or older.  Do any of you?  The code to try is very simple:


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);
  }
  });
}

After you paste it into any .java file of your choosing (and fixing imports), 
just run the file, click on the “Busy” button once, then on the “Normal” 
button, and then one last time on “Busy”.  On Linux and Windows, the cursor 
changes each time.  On Mac, the cursor doesn’t change to “Busy” the second time 
around :-(

Unless you guys see anything wrong with this code, I will file a bug report in 
Oracle’s Bug database.

Thanks a bunch,
Tom

Reply via email to