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

[Linux] scene coordinates are defined incorrectly.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: fx2.1
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Labels:
    • Environment:

      2.1.0b16.

      Description

      Run this code on linux and windows:

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class CoordinatesIssue extends Application {

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

          @Override
          public void start(final Stage stage) throws Exception {
              final Button b = new Button("Press me");
              
              VBox vb = new VBox();
              vb.getChildren().addAll(b);
              final Scene scene = new Scene(vb, 300, 300);
              
              b.setOnAction(new EventHandler<ActionEvent>(){

                  @Override
                  public void handle(ActionEvent t) {
                      System.out.println("X:" + stage.getX() + " Y:" + stage.getY());
                      System.out.println("X:" + scene.getX() + " Y:" + scene.getY());
                      System.out.println("Button X:" + b.getBoundsInLocal().getMinX() + " Button Y:" + b.getBoundsInLocal().getMinY());
                      System.out.println("Button X:" + b.getBoundsInParent().getMinX() + " Button Y:" + b.getBoundsInParent().getMinY());
                      System.out.println("Button X:" + b.getLayoutBounds().getMinX() + " Button Y:" + b.getLayoutBounds().getMinY());
                      System.out.println("Button X:" + b.getLayoutY() + " Button Y:" + b.getLayoutY());
                  }
              });
              
              stage.setScene(scene);
              stage.show();
          }
      }

      If you press button:

      Sample output for windows:
      run:
      X:802.0 Y:234.0
      X:8.0 Y:30.0
      Button X:-1.399999976158142 Button Y:-1.399999976158142
      Button X:-1.399999976158142 Button Y:-1.399999976158142
      Button X:0.0 Button Y:0.0
      Button X:0.0 Button Y:0.0

      Sample output for linux:
      run:
      X:802.0 Y:234.0
      X:0.0 Y:0.0
      Button X:-1.399999976158142 Button Y:-1.399999976158142
      Button X:-1.399999976158142 Button Y:-1.399999976158142
      Button X:0.0 Button Y:0.0
      Button X:0.0 Button Y:0.0

      Look on the second line of output: scene coordinates in linux don't take decoration into account.

      That leads to situation when awt robot clicks in wrong place and that makes ALL tests which uses actions to fail on linux.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                msladecek Martin Sládeček
                Reporter:
                akirov Alexander Kirov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: