boolean foundValid = false; char[] nameChars = hd.name.toCharArray(); for ( int loop = 0; !foundValid && loop < nameChars.length; loop++ ) { if ( !Character.isWhitespace( nameChars[loop] ) ) { foundValid = true; } } if ( !foundValid ) { new AlertDialog( frame, "Load a Game", "Error: enter a player name." ).show(); return; }
    public void loadGame() {        FileDialog fd =            new FileDialog(frame, "Select saved game...", FileDialog.LOAD);        fd.setDirectory(".");        //Using the FilenameFilter class would be the appropriate way to        // filter for certain extensions, but it's broken under windoze.  See        // http://developer.java.sun.com/developer/bugParade/bugs/4031440.html        // for details.  The hack below is better than nothing.        fd.setFile("*.sav");        fd.show();        if (fd.getFile() == null) {            return;        }        HostDialog hd = new HostDialog(frame);        hd.show();        if (hd.name == null || hd.serverPass == null || hd.port == 0) {            return;        }        // kick off a RNG check        megamek.common.Compute.d6();        // start server        server = new Server(hd.serverPass, hd.port);        if (!server.loadGame(new File(fd.getDirectory(), fd.getFile()))) {            new AlertDialog(frame, "Load a Game", "Error: unable to load game file.").show();            server = null;            return;        }        client = new Client(hd.name, "localhost", hd.port);		launch(client.getFrame());        optdlg = null;    }