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

Mouse cursor not updated immediate

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8u40
    • javafx
    • None
    • Win7 64bit

      Tried to implement a global wait cursor, via scene.setCursor.

      The problem is that this command doesn't set the cursor immediate. Not all applications can do every method call async.


      Test application:

      public class WaitCursorTest extends Application
      {
      private Scene scene;

      public static void main(String[] args)
      {
      launch(args);
      }

      @Override
      public void start(Stage primaryStage)
      {
      Button butWait = new Button("Show WAIT cursor");
      butWait.setOnAction(e ->
      {
      scene.setCursor(Cursor.WAIT);

      try
      {
      Thread.sleep(5000);
      }
      catch (Exception ex)
      {
      //ignore
      }
      finally
      {
      scene.setCursor(Cursor.DEFAULT);
      }
      });

      BorderPane panButton = new BorderPane();
      panButton.setCenter(butWait);

      scene = new Scene(panButton, 800, 600);

      primaryStage.setScene(scene);
      primaryStage.setTitle("JavaFX FlowPane Test");
      primaryStage.show();
      }

      }

      Same or similar was possible with Swing without problems:

      public class WaitCursorSwingTest extends JFrame
      {
      public static void main(String[] args)
      {
      new WaitCursorSwingTest();
      }

      public WaitCursorSwingTest()
      {
      BorderLayout blMain = new BorderLayout();

      JButton butWait = new JButton("Show WAIT cursor");
      butWait.addActionListener(l ->
      {
      getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      getGlassPane().setVisible(true);

      try
      {
      Thread.sleep(5000);
      }
      catch (Exception ex)
      {
      //ignore
      }
      finally
      {
      getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      getGlassPane().setVisible(false);
      }
      });

      FlowLayout flCenter = new FlowLayout();

      JPanel panCenter = new JPanel(flCenter);
      panCenter.add(butWait);

      setLayout(blMain);
      add(panCenter);

      setSize(800, 600);
      setLocationRelativeTo(null);
      setVisible(true);
      }

      }

            kcr Kevin Rushforth
            rjahnjfx René Jahn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: