public void connectOk()
  {
    try
    {
      if(chat.connected)
        chat.disconnect();

      userlist.reset();

      // must make copies of strings here since dialog is closed afterward!
      String address = new String(cd.address.getText());
      String port = new String(cd.port.getText());
      String name = new String(cd.name.getText());
      String pass = new String(cd.pass.getText());

      cd.end();

      chat.connect(address, port, applet ? false : cd.ssl.isSelected());

      if(chat.connected)
      {
        // send user name and password
        if(name.length() > 0 && pass.length() <= 0)
          chat.out.write(".n" + name + "\n");
        if(name.length() > 0 && pass.length() > 0)
          chat.out.write(".n" + name + "=" + pass + "\n");
        chat.out.flush();
            
        // send .Z for user list
//        chat.out.write(".Z\n");
//        chat.out.flush();

        // report client name
        chat.out.write("% has connected using JoeClient\n");
        chat.out.flush();
      }
      else
      {
        JOptionPane.showMessageDialog(win, "Server Not Found.");
      }
    }
    catch(IOException e)
    {
      //e.printStackTrace();
    }
  }