View Single Post
  #10 (permalink)  
Old 10-23-2007, 07:10 AM
adlb1300 adlb1300 is offline
Member
 
Join Date: Jul 2007
Posts: 46
adlb1300 is on a distinguished road
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:

Code:
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
Reply With Quote