かなり大きいペイン(スクロールペインの子)に新しいドラッグ可能なノードを生成するアプリを作成しようとしていますが、このノードは画面の中央に生成されます。スポーンされたノードがあらかじめ設定されています
Q:これらの新しい画像ビューのX、Y座標を事前設定する方法はありますか?
ありがとうございます。例えば
:
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
Bounds bounds = scrollPane.getBoundsInLocal();
Bounds screenBounds = scrollPane.localToScreen(bounds);
int mX = (int) screenBounds.getMinX();
int mY = (int) screenBounds.getMinY();
Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
int x = (int) ((primScreenBounds.getWidth() - mX) /4);
int y = (int) ((primScreenBounds.getHeight() - mY) /4);
/*
System.out.println("X coords:" +x);
System.out.println("Y coords:" +y);
*/
pane.getChildren().addAll(new ImageView(imgvw.getImage()));
//somehow set coordinates of new ImageView
}
});
私がしたいのは、 'new ImageView'の産卵用の' int x'と 'int y'座標を使うことですが、それを理解することはできません。 :/ – TomT