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);
}
}
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);
}
}
- relates to
-
JDK-8088984 [Windows] Very poor performance of application (or Menus) when using an Animation
- Open