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

Incorrect computation of y screen coordinates in ChoiceBox

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u45
    • javafx

      FULL PRODUCT VERSION :
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Ubuntu Linux 64-bit

      A DESCRIPTION OF THE PROBLEM :
      When displaying a ChoiceBox inside a Popup and then choosing one of the choices from the ChoiceBox a MouseExitEvent is delivered to the containing Popup. In this event the event.getScreenY Coordinate is incorrect.

      However I'm not sure if even the delivery of the MouseExitEvent to the Popup is correct, maybe that's the problem already.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Run the sample program
      2) Click the button to open the popup
      3) Click the ChoiceBox and select another value, e.g. 'c'.
      4) See output of program


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package bugreports;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ChoiceBox;
      import javafx.scene.layout.Pane;
      import javafx.stage.Popup;
      import javafx.stage.Stage;

      import java.awt.*;


      public class IncorrectOnScreenCoordinatesChoiceBox extends Application
      {
      // Simple popup as container for the ChoiceBox
      public static class Container extends Popup
      {
      public Container()
      {
      final Pane content = new Pane();
      content.setStyle("-fx-background-color: white; -fx-border-color: black; -fx-border-width: 2");
      content.setPrefSize(200, 200);

      final ChoiceBox<String> box = new ChoiceBox<>();
      box.getItems().addAll("a", "b", "c", "d");
      box.getSelectionModel().select(0);

      content.setOnMouseExited(event -> {
      final String out = "%5s: %f, %f";

      // compare the mouse position as reported by awt with the mouse position on screen by the event
      final Point awt = MouseInfo.getPointerInfo().getLocation();

      System.err.println(String.format(out, "event", event.getScreenX(), event.getScreenY()));
      System.err.println(String.format(out, "awt", awt.getX(), awt.getY()));
      });

      content.getChildren().add(box);
      getContent().add(content);
      }
      }


      @Override
      public void start(final Stage primaryStage) throws Exception
      {
      // just opens the popup
      final Button b = new Button("Click me");
      b.setOnAction(event -> {
      final Container c = new Container();
      c.show(b.getScene().getWindow());
      });

      primaryStage.setScene(new Scene(b));
      primaryStage.show();
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Query awt MouseInfo for correct on screen position of cursor.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: