title: Issue with Java Server class and socket connections
body: <p>I am trying to set up a server class, and i'm running into a issue in which no error is being thrown.</p>
  
  <pre><code>import java.io.*;
  import java.net.*;
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  public class Server extends JFrame implements Runnable{
  
  private static final long serialVersionUID = 1L;
  private JTextField userText;
  private JTextArea chatWindow;
  private ObjectOutputStream output;
  private ObjectInputStream input;
  private ServerSocket server;
  private Socket connection;
  
  //constructor
  public Server(){
      super("Server");
      userText = new JTextField();
      userText.setEditable(false);
      userText.addActionListener(
          new ActionListener(){
              public void actionPerformed(ActionEvent event){
                  sendMessage(event.getActionCommand());
                  userText.setText("");
              }
          }
      );
      add(userText, BorderLayout.NORTH);
      chatWindow = new JTextArea();
      add(new JScrollPane(chatWindow));
      setSize(300, 150); //Sets the window size
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);   
  }
  
  public void run(){
      try{
          server = new ServerSocket(6789, 100); //6789 is a dummy port for testing, this can be changed. The 100 is the maximum people waiting to connect.
          while(true){
              try{
                  //Trying to connect and have conversation
                  waitForConnection();
                  setupStreams();
                  whileChatting();
              }catch(EOFException eofException){
                  showMessage("\n Server ended the connection! ");
              } finally{
                  closeConnection(); //Changed the name to something more appropriate
              }
          }
      } catch (IOException ioException){
          ioException.printStackTrace();
      }
  }
  //wait for connection, then display connection information
  private void waitForConnection() throws IOException{
      showMessage(" Waiting for someone to connect... \n");
      connection = server.accept();
      showMessage(" Now connected to " + connection.getInetAddress().getHostName());
  }
  
  //get stream to send and receive data
  private void setupStreams() throws IOException{
      output = new ObjectOutputStream(connection.getOutputStream());
      output.flush();
  
      input = new ObjectInputStream(connection.getInputStream());
  
      showMessage("\n Streams are now setup \n");
  }
  
  //during the chat conversation
  private void whileChatting() throws IOException{
      String message = " You are now connected! ";
      sendMessage(message);
      ableToType(true);
      do{
          try{
              message = (String) input.readObject();
              showMessage("\n" + message);
          }catch(ClassNotFoundException classNotFoundException){
              showMessage("The user has sent an unknown object!");
          }
      }while(!message.equals("CLIENT - END"));
  }
  
  public void closeConnection(){
      showMessage("\n Closing Connections... \n");
      ableToType(false);
      try{
          output.close(); //Closes the output path to the client
          input.close(); //Closes the input path to the server, from the client.
          connection.close(); //Closes the connection between you can the client
      }catch(IOException ioException){
          ioException.printStackTrace();
      }
  }
  
  //Send a mesage to the client
  private void sendMessage(String message){
      try{
          output.writeObject("SERVER - " + message);
          output.flush();
          showMessage("\nSERVER -" + message);
      }catch(IOException ioException){
          chatWindow.append("\n ERROR: CANNOT SEND MESSAGE, PLEASE RETRY");
      }
  }
  
  //update chatWindow
  private void showMessage(final String text){
      SwingUtilities.invokeLater(
          new Runnable(){
              public void run(){
                  chatWindow.append(text);
              }
          }
      );
  }
  
  private void ableToType(final boolean tof){
      SwingUtilities.invokeLater(
          new Runnable(){
              public void run(){
                  userText.setEditable(tof);
              }
          }
      );
   }
   }
  
  
  
  import java.awt.Dimension;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JOptionPane;
  
  public class Menu extends JFrame implements ActionListener{
  
  private static final long serialVersionUID = 1L;
  private JButton server;
  private JButton client;
  private static String Host;
  
  public Menu(){
  
      this.getContentPane().setPreferredSize(new Dimension(300, 300));
  
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      this.setLayout(null);
      this.pack();
  
      this.setLocationRelativeTo(null);
  
      server = new JButton();
      server.setText("server");
      server.setBounds(0, 0, 300, 150);
      server.addActionListener(this);
      client = new JButton();
      client.setText("client");
      client.setBounds(0, 150, 300, 150);
      client.addActionListener(this);
  
      this.add(server);
      this.add(client);
  
      this.setVisible(true);
  }
  
  
  public void actionPerformed(ActionEvent e) {
      if(e.getSource() == server){
          Server s = new Server();
          s.run();
      }
      if(e.getSource() == client){
          Host = JOptionPane.showInputDialog("Enter Server I.P.");
          Client c = new Client(Host);
          c.run();
      }
  
  }
  
  public static void main(String[] args){
      new Menu();
  }
  
  }
  </code></pre>
  
  <p>The JFrame is created, but can only be exited by the termination button in eclipse, not the default_exit_on_close operation, and is see through (not opaque as it should be). The client class acts the same way, leading me to believe that the issue is the:</p>
  
  <pre><code> Server s = new Server();
          s.run(); 
  </code></pre>
  
  <p>since if i have the main method call that, everything works fine.</p>