title: Clicking the cancel button showInputDialogue
body: <p>I have a question in regards  to pressing the cancel button of my inputDialoguebox. I have asked a similar question before so I apologize if I seem to repeat myself. </p>
  
  <p>The main problem I have is that my code executes regardless of me pressing cancel and a socket connection does get made even if I don't add any input. </p>
  
  <p>Why does this happen and how can I avoid this?</p>
  
  <pre><code>String input = "";
             try
             {
                 InetAddress host = InetAddress.getLocalHost();
                 String hostAddress = host.getHostAddress();
  
                 //setting label to host number so as to know what number to use
                 labHostName.setText("(" + hostAddress + ")");
  
                 input = JOptionPane.showInputDialog(null,"Please enter host name to access server(dotted number only)...see number on frame", "name", JOptionPane.INFORMATION_MESSAGE); 
  
                 if(input != null &amp;&amp; "".equals(input))//input != null &amp;&amp; input.equals(""))   
                 {
                     throw new EmptyFieldsException();
  
  
  
                 }
                 else if(input != null &amp;&amp; !input.equals(hostAddress))
                 {
                     throw new HostAddressException();
  
  
                 }
  
                 else
                 {
  
                      clientSocket = new Socket(input, 7777);
  </code></pre>
  
  <p>So with the code being the way it is at the moment the clientsocket connection is made even if I do press cancel. Is the reason for this perhaps because I have the Server and Client as two seperate programs on the same machine? How can I avoid this from happening?</p>