不遵循JavaFX中父窗格的填充的行

时间:2015-07-30 12:28:02

标签: java javafx-8

以下是代码:

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Line;
import javafx.stage.Stage;

public class TestCoordinates extends Application {

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

    @Override
    public void start(Stage primaryStage) {
        Pane pane = new Pane();
        Pane pane1 = new Pane();
        pane1.setPadding(new Insets(10, 10, 10, 10));
        pane1.getChildren().addAll(pane);
        Point2D p1 = pane.localToParent(0, 0);
        Point2D p2 = pane.localToParent(50, 50);
        Line line = new Line(p1.getX(), p1.getY(), p2.getX(), p2.getY());
        pane.getChildren().addAll(line);
        primaryStage.setScene(new Scene(pane1));
        primaryStage.show();
    }
}

我正在尝试在内部窗格中绘制一条线,但它似乎坚持坚持在外部窗格中:

enter image description here

有什么建议吗?

0 个答案:

没有答案