anchor when extended not working

I created my own chart with x and y axises. I found the present choices of charts did not suite my needs. I have managed to built my chart to my likings and now I would like to add all the components to an object that extends AnchorPane. The end results is that my code compiles with no errors, no runtime errors but I don't see any of my panes that I created. I was wondering what the correct procedure is to extend AnchorPane.

This is the code inside my class that extends Application. Works like a charm:

        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();

When I put the code inside a class that extends AnchorPane:

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);

And then in my class that extends Application I have:

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

It only displays a black window.

Answers


Figure out what I was doing wrong. I have "void" in my constructor call making a method.


Need Your Help

Will an optimiser deduce mathematical expressions based on compile-time constants?

c++ gcc compiler-optimization

If I have some mathematical equations which rely on inputs which can be zero or non-zero (template argument, known at compile time), will the optimiser evaluate the equations and optimise out

Want to display text from a UITableViewCell to a Local Notification alertBody

objective-c uitableview variables uilocalnotification

When the cell grays out, I want to create a Local Notification. In the alertBody want to have the text read what is in the cell and send that to the local notification. Only the Alert! displays wit...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.