Javafx 锚在伸出时不起作用

Javafx 锚在伸出时不起作用,javafx,extend,pane,Javafx,Extend,Pane,我用x轴和y轴创建了自己的图表。我发现目前的图表选择不符合我的需要。我已经按照自己的喜好制作了我的图表,现在我想将所有组件添加到一个扩展AnchorPane的对象中。最终的结果是,我的代码编译时没有错误,没有运行时错误,但我没有看到我创建的任何窗格。我想知道延长锚烷的正确程序是什么 这是我的类中扩展应用程序的代码。工作起来很有魅力: Vector <String[]> v = new Vector<String[]>(); double

我用x轴和y轴创建了自己的图表。我发现目前的图表选择不符合我的需要。我已经按照自己的喜好制作了我的图表,现在我想将所有组件添加到一个扩展AnchorPane的对象中。最终的结果是,我的代码编译时没有错误,没有运行时错误,但我没有看到我创建的任何窗格。我想知道延长锚烷的正确程序是什么

这是我的类中扩展应用程序的代码。工作起来很有魅力:

        Vector <String[]>  v = new Vector<String[]>();
        double highest_high = 0;
        double lowest_low = 0;
        AnchorPane anchorpane = new AnchorPane();


        double xaxisHeight = 20;
        double yaxisWidth = 60;
        double chartYAdjustment = 40;
        double barGap = 3;
        double bars = 15;
        final Chart chart = new Chart(v, yaxisWidth, xaxisHeight, highest_high, lowest_low, chartYAdjustment, barGap);
        final YAxis yaxis = new YAxis(yaxisWidth, highest_high, lowest_low);
        final XAxis xaxis = new XAxis(xaxisHeight, barGap, bars);

        AnchorPane.setTopAnchor(yaxis, 0.0);
        AnchorPane.setRightAnchor(yaxis, 0.0);
        AnchorPane.setBottomAnchor(yaxis, 20.0);        


        AnchorPane.setLeftAnchor(xaxis, 0.0);
        AnchorPane.setRightAnchor(xaxis, 60.0);
        AnchorPane.setBottomAnchor(xaxis, 0.0);     

        AnchorPane.setLeftAnchor(chart, 0.0);
        AnchorPane.setTopAnchor(chart, 0.0);
        AnchorPane.setBottomAnchor(chart, 0.0);
        AnchorPane.setRightAnchor(chart, 0.0);

        anchorpane.getChildren().addAll(chart, yaxis, xaxis);

        Scene s = new Scene(anchorpane, 800, 400, Color.BLACK);
        stage.setScene(s);
        stage.show();

它只显示一个黑色窗口。

找出我做错了什么。我的构造函数调用中有一个“void”方法

public class Main extends AnchorPane{

    public void Main(){
        Vector <String[]>  v = new Vector<String[]>();
        double highest_high = 0;
        double lowest_low = 0;      

        double xaxisHeight = 20;
        double yaxisWidth = 60;
        double chartYAdjustment = 40;
        double barGap = 3;
        double bars = 15;
        final Chart chart = new Chart(v, yaxisWidth, xaxisHeight, highest_high, lowest_low, chartYAdjustment, barGap);
        final YAxis yaxis = new YAxis(yaxisWidth, highest_high, lowest_low);
        final XAxis xaxis = new XAxis(xaxisHeight, barGap, bars);

        AnchorPane.setTopAnchor(yaxis, 0.0);
        AnchorPane.setRightAnchor(yaxis, 0.0);
        AnchorPane.setBottomAnchor(yaxis, 20.0);        


        AnchorPane.setLeftAnchor(xaxis, 0.0);
        AnchorPane.setRightAnchor(xaxis, 60.0);
        AnchorPane.setBottomAnchor(xaxis, 0.0);     

        AnchorPane.setLeftAnchor(chart, 0.0);
        AnchorPane.setTopAnchor(chart, 0.0);
        AnchorPane.setBottomAnchor(chart, 0.0);
        AnchorPane.setRightAnchor(chart, 0.0);

        getChildren().addAll(chart, yaxis, xaxis);
Main main = new Main();
Scene s = new Scene(main, 800, 400, Color.BLACK);
            stage.setScene(s);
            stage.show();