I have added an if...else statement to handle situations when the inputted number is outside of the specified range of 1 to 5. If the number is outside of the range a JOptionPane opens containing an error message. I would like to make it so that clicking the ok button on this pane will bring up the input dialog box again. Any ideas on how I would do this?
Here is the code I have right now for the section:
if((gridSquares >= 1) && (gridSquares <= 5)){
// Creates frame that holds the grid which is produced by the CreateGridRx
// class
CreateGridRx test = new CreateGridRx(gridSquares); // create new grid
JFrame f = new JFrame(); // creates new JFrame object
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(test); // add grid to JFrame
f.pack(); // sets size of frame
f.setLocation(200,200); // sets location of frame
f.setVisible(true); // show the frame
}
else {
// Error message that is shown if inputted number is outside of range.
JOptionPane.showMessageDialog(null, "Number must be between 1 and 5", "Input Error", JOptionPane.ERROR_MESSAGE);
} // end else
Thanks