I am trying to display an arraylist in a gui. However I am getting some troubles. I need to check if my game is legal, if it is not legal then it calls getProblems which displays the arraylist. I tried to call getProblems directly in the GUI class however it will show the array as empty. (Since it's not checking if it's legal). I also tried to call isLegal then getProblems but you cannot do this in a JOptionPane
. Any tips on how I can call it accross?
GetProblems class
protected List < String > getProblems() {
return displayOutput;
}
IsLegal Class
public boolean isLegal() {
boolean legality;
if (checkRowConstraints().isEmpty()) {
legality = true;
} else {
getProblems();
legality = false;
}
return legalCheck;
}
GUI:
public void actionPerformed(ActionEvent e) {
if (!(puzzle.isLegal())) {
JOptionPane.showMessageDialog(FutoshikiFrame.this,
puzzle.getProblems(),
"You made a mistake!",
JOptionPane.INFORMATION_MESSAGE);
Here is difference between Actual display of GUI result and result i'm trying to get.
Further Problem found: I need to return the arraylist then empty it. Fixed