title: java - input dialog validation
body: <p>I'm trying to implement <strong>A* algorithm</strong> in java. The user is requested to type the width and height of the grid-to-be. My problem is in validating that input. Here is my code:   </p>
  
  <pre><code>public class Map extends java.awt.Panel implements Serializable
  {
  JFrame frame = new JFrame();
  String rows =  JOptionPane.showInputDialog(frame,
                  "Συμπληρώστε τον αριθμό γραμμών του πλέγματος: \n",
                  "Δημιουργία πλέγματος",
                  JOptionPane.PLAIN_MESSAGE);
  String cols =  JOptionPane.showInputDialog(frame,
                  "Συμπληρώστε τον αριθμό στηλών του πλέγματος: \n",
                  "Δημιουργία πλέγματος",
                  JOptionPane.PLAIN_MESSAGE);
  
  int rowsnum = Integer.parseInt(rows); 
  int colsnum = Integer.parseInt(cols);
  GridCell gridCell[][] = new GridCell[rowsnum][colsnum];
  
  public Map()
  {
          super();
  
      setLayout(new GridLayout(rowsnum,colsnum)); 
      for(int i=0;i&lt;rowsnum;i++){ 
          for(int j=0;j&lt;colsnum;j++){
             gridCell[i][j] = new GridCell();
             gridCell[i][j].setPosition(new Point(i,j));
             add(gridCell[i][j]);
          }
      }
  }
  </code></pre>
  
  <p>I've tried to check the input in a new method, but my problem is that I need to have access to <code>rowsnum</code> , <code>colsnum</code> and <code>gridcell[]</code> from the other classes of my program. </p>
  
  <p>I'm new in Java and I'd very much appreciate any help. :-)</p>