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

Cursor problem in SwingComponents

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: fx1.0
    • Fix Version/s: fx1.3
    • Component/s: javafx
    • Environment:

      JavaFX 1.1, Vista x64, Java 1.6 Update 12

      Description

      If a subclass of SwingComponent uses a cursor other than the default cursor, the custom cursor will only show when above certain parts of the SwingComponent.

      For example, in the application below, the JButton should have a hand cursor, but the hand cursor is only shown when the cursor is in the top left quadrant of the button (if application window located on the middle of the computer screen). If, however, the application window is placed in the top left corner on the computer screen, the entire button will show the hand cursor (i.e. it will work).

      When the cursor is moved in an area of the button where it is shown, it will still flicker a bit and for short periods of time switch back to the default cursor.

      The problem occurs in standard execution and browser execution (other execution models not tested).

      package netbeansproject;

      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.scene.text.Font;
      import javafx.wirefusion.*;
      import javax.swing.JButton;

      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javafx.ext.swing.SwingComponent;
      import javafx.scene.Cursor;


      var presentation = MySwingButton {
          width: 400
          height: 300
      };

      Stage {
          title: "Presentation"
          scene: Scene {
              width: 400
              height: 300
              content: [
                  presentation
              ]
          }
      }

      class MySwingButton extends SwingComponent {
          var button: JButton;

          public override function createJComponent(){
             if (button == null) {
                  button = new JButton("Test");
                  button.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
              }
              return button;
          }
      }


      An observation that may help finding the problem: The contains(x,y) method of the SwingComponent subclass receives a mixture of correct values and values that are transformed to 2*x,2*y (when presentation in the middle of the screen).

        Attachments

          Activity

            People

            • Assignee:
              rbair Richard Bair
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: