public String addHost()
    {
        try {
            URL whatismyip = new URL("http://checkip.amazonaws.com/");
    BufferedReader in = new BufferedReader(new InputStreamReader(
                    whatismyip.openStream()));

    String ip = in.readLine(); //you get the IP as a String
    //System.out.println(ip);
    int an = JOptionPane.showConfirmDialog(connect, "Host the server through the internet?", "Server Type?", JOptionPane.YES_NO_OPTION);
    if (an!=0)
    {
        ip = InetAddress.getLocalHost().getHostAddress();
    }
    String yes = JOptionPane.showInputDialog("Server Name?");
    if (yes!=null)
    {
        serverName=yes.replaceAll("[^A-Za-z0-9\\s]","").replaceAll(" ", "");
    
    CTD.addServer(serverName.length()>0?serverName:"SERVER", ip);
    return ip;
    }
    else
    {
        serverName="SERVER";
        CTD.addServer(serverName.length()>0?serverName:"SERVER", ip);
        //ip = InetAddress.getLocalHost().getHostAddress();
    }
    return "NO";
        } catch (IOException | HeadlessException ex) {
            //Logger.getLogger(APPLET.class.getName()).log(Level.SEVERE, null, ex);
            return "localhost";
        }
    }