I have an array containing potential moves for a board game in one file. The display panel that informs the players of current state of game is in another file. I am trying to display this potential moves array as a menu (or table/combo box) in the display panel but I am having problems accessing the array because both codes are in separate files. Any thoughts on how I could display the contents would be greatly appreciated. The array is in my Main.java which contains loads of code but I will post the display panel code here. The array is in a function that returns nothing and prints to the console okay. I hope I have been able to articulate my problem, apologies in advance. calculatemoves function is in Main.java while displayLabels function is in Displaypanel.java
I have tried to create an object of Main but it is not possible because it extends Application(using JavaFX).
public void calculateMoves(int dice1, int dice2){
String[] potentialMoves = new String[500];
int k=0;
....
System.out.println("reach");
System.out.println("k: "+k);
for(k=k-1; k>=0; k--){
System.out.println(potentialMoves[k]);
}
ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.getItems().addAll(potentialMoves);
}
public void displayLabels(){
if(gridSize < 31) {
int numOfLabels = gridSize;
int j = 0;
for (int i = numOfLabels; i > numOfLabels - 31; i--) {
GridPane.setConstraints(labels[i - 1], 0, j);
grid.getChildren().addAll(labels[i - 1]);
j++;
if (i - 1 == 0) break;
}
}
13-7 8-3 13-7 7-2 24-18 8-3 24-18 13-8 24-18 18-13 should be printed as a menu. This is the sort of result I get on my console at the moment.