title: The input Dialogue box in Java
body: <p>I am busy with a project for school where I use the InputDialogbox to get the hostname from the user so as to make a client socket connection.</p>
  
  <p>There are two things that puzzle me a bit.</p>
  
  <p>Firstly I make a connection Server Side and then I make the client connection as follow.</p>
  
  <pre><code>input = JOptionPane.showInputDialog(null, "Please enter host name to access" +
                    "server(dotted number only)...see number on frame", "name",
                     JOptionPane.INFORMATION_MESSAGE); 
  
  clientSocket = new Socket(input, 7777);
  </code></pre>
  
  <p>what puzzles me as that if I press enter in the Dialogue box without making any entry...i.o.w without specifying the IPAddress the connection to the socket is made regardless. Why is that?</p>
  
  <p>To overcome this 'problem' I decided to try to get the user to make an entry in the dialogue box</p>
  
  <pre><code>if(input.equals(""))
  {
      throw new EmptyFieldsException();
  }
  </code></pre>
  
  <p>The thing is that now if I click on cancel I get a NullPointerException.
  How can I cancel the Dialogue box without getting this exception?</p>
  
  <p>Kind regards
  Arian</p>