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

[Glass, Graphics] Performance issue when tracking mouse events

XMLWordPrintable

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

      I have a simple program that allows me to drag a circle around a scene. I'm not sure if I'm doing something wrong but the circle always seems to lag the position of the mouse. It just feels wrong.

      This is using Java 8 build b117 and happens on both Windows 7 64bit and Linux 64bit.

      To reproduce run the code below and drag the circle about quite quickly.

      Here is the code:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.layout.FlowPane;
      import javafx.scene.shape.Circle;
      import javafx.stage.Stage;

      public class DragTest extends Application {
          @Override
          public void start(Stage stage) throws Exception {
              FlowPane flowPane = new FlowPane();
              Scene scene = new Scene(flowPane, 500, 500);
              stage.setScene(scene);
              double circleRadius = 20;
              Circle circle = new Circle(circleRadius);
              circle.setOnMouseDragged(mouseEvent -> {
                  circle.setTranslateX(mouseEvent.getSceneX() - circleRadius);
                  circle.setTranslateY(mouseEvent.getSceneY() - circleRadius);
              });
              flowPane.getChildren().add(circle);
              stage.show();
          }

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

            Unassigned Unassigned
            ndarcy Nick D'Arcy
            Votes:
            6 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Imported: