0

I'm making Tetris in JavaFX and set up a the gameboard of 200 Panes set up in a 10x20 grid. I have added all of those objects to my controller. However, I would like to set all of them up in an array so that it is easier to handle the coordinates. Pane[][] does not seem to be allowed, giving the error in Eclipse "Type mismatch: cannot convert from Pane to Pane[]" for some of the listed Pane object and "pane01 cannot be resolved to a type" for others. Can Pane objects simply not be put into an array? I could have sworn I was able to with ToggleButtons in a previous project, but I can't remember for sure. Thanks ahead.

I set up the Panes in the controller similar to:

@FXML
private Pane pane00, pane10, pane20,
             pane01, pane11, pane21;

with the numbers representing the x/y coordinates. And was trying to put them into an array as:

public Pane[][] gameBoard = {pane00, pane10, pane20},
                            {pane01, pane11, pane21};

I originally tried doing the above array setup just under the @FXML as the main setup of it in the controller, but it had the "pane01 cannot be resolved to a type" error on some of the objects (note: only SOME, others were fine for whatever reason)

1 Answer 1

1

You need to add one more opening and closing braces to consider it 2d array

solution:

public Pane[][] gameBoard = {{pane00, pane10, pane20},
                             {pane01, pane11, pane21}};
Sign up to request clarification or add additional context in comments.

2 Comments

If I could go crawl in a hole now and never be seen by the world again, that would be nice. Thank you very much
@fiveandten if you accpet this answer please check it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.