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

[Mouse] getX() and getY() for MouseEvent may return -1

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • 8u20
    • 8
    • javafx
    • java version "1.8.0"
      Java(TM) SE Runtime Environment (build 1.8.0-b132)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

      Windows 7, 64 bit

    Description

      Compile and run next sample:

      /*
       * To change this license header, choose License Headers in Project Properties.
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      package javafxapplication9;

      import java.util.List;
      import javafx.application.Application;
      import javafx.css.CssMetaData;
      import javafx.css.Styleable;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.input.MouseEvent;
      import javafx.scene.layout.CornerRadii;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      /**
       *
       * @author Ladislav Török
       */
      public class JavaFXApplication9 extends Application {

          @Override
          public void start(Stage primaryStage) {
              Button btn = new Button();
              btn.setText("Say 'Hello World'");
              btn.setOnMouseMoved((EventHandler<? super MouseEvent>) event -> {
                  System.out.println("gteX(), getY(): " + event.getX() + ", " + event.getY());
              });

              StackPane root = new StackPane();
              root.getChildren().add(btn);

              Scene scene = new Scene(root, 300, 250);

              primaryStage.setTitle("Hello World!");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }

      }

      Move mouse cursor over button, set cursor to top left corner of button.

      Attachments

        Activity

          People

            msladecek Martin Sládeček
            ltorokjfx Ladislav Török (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: