我很难找出形状的正确 layoutx / layouty 值。请看一下这个例子:
package test;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.shape.Line;
public class TestLinePosition
extends Application
{
private Line line;
private Scene getScene()
{
Group group = new Group();
line = new Line(10, 10, 60, 10);
group.getChildren().add(line);
Scene scene = new Scene(group, 640, 480);
return scene;
}
@Override
public void start(Stage stage) throws Exception
{
stage.setScene(getScene());
stage.show();
System.out.println("x: " + line.getLayoutX() + ", y: " + line.getLayoutY());
}
public static void main(String[] args)
{
Application.launch(args);
}
}
如果我运行这个程序,该行似乎从 10、10 开始按预期定位。但是 layoutx 和 layouty 值为 0、0。
谁能给我解释这种行为和/或告诉我如何找出实际位置?
谢谢你,罗杰