Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+9 votes

I am in the second part of the lab, for B5 it says " change it from a plain old Pane to a
BorderPane, so that you can place the Canvas in its center (using root.setCenter())," but in my start method, I change new Pane(canvas) to new BorderPane(canvas) but when I try to set the root to the center, the only option it gives me is setCenterShape. is it the same thing? I would be able to tell if I run it but so far in the lab I can't run it yet. Thank you!

asked in CSC305 Fall 2023 by (3k points)

1 Answer

+3 votes

I do not believe so. make sure your variable you use to create your BorderPane object is of type BorderPane not type Pane.

e.g. BorderPane root = new BorderPane(canvas); NOT
Pane root = new BorderPane(canvas);

Had this same problem and Dr. Stonedahl had me change my variable type and it worked. BorderPane is a subclass of Pane and to access the unique methods of BorderPane(like .setCenter() and .setTop()) the variable must be of type BorderPane not type Pane

answered by (3.8k points)
...