.
*
* Copyright (C) 1996 Massachusetts Institute of Technology.
* Please do not redistribute without obtaining permission.
*/
package cs101.awt;
/**
* Manages a top level query dialog box to get port connection information.
* To display the dialog box, use ask(); to extract the port number, use
* getPort().
*
* Relies heavily on QueryDialog.
*
*
Copyright (c) 1998 Massacuhsetts Institute of Technology
*
* @author Todd C. Parnell, tparnell@ai.mit.edu
* @author Nathan Williams
* @author Lynn Andrea Stein
* @version $Id: ServerDialog.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $
*
* @see cs101.awt.QueryDialog
* @see #ask
* @see #getPort
*/
public class ServerDialog {
protected QueryDialog qd;
protected String[] answers,
questions;
/**
* Creates the dialog information.
* To show the dialog, call ask().
* To retrieve information, use int getPort().
*/
public ServerDialog() {
this.questions = new String[1];
this.questions[0] = "Port";
this.answers = new String[1];
this.answers[0] = "4321";
this.qd = new QueryDialog("Please enter the port to listen on.",
this.questions,
this.answers);
}
/**
* Actually display the query dialog and get the answers from the user.
*
* @see #getPort()
*/
public synchronized void ask() {
this.answers = this.qd.ask();
}
/**
* Return the port number from the user. Not guaranteed to be sensible
* if ask hasn't aready been called.
*
* @see #ask()
*/
public synchronized int getPort() {
try {
return Integer.parseInt( this.answers[0] );
} catch ( NumberFormatException e ) {
throw new RuntimeException("Bad port number '"+answers[0]+"'");
}
}
}
/*
* $Log: ServerDialog.java,v $
* Revision 1.1.1.1 2002/06/05 21:56:32 root
* CS101 comes to Olin finally.
*
* Revision 1.5 1998/07/24 17:06:31 tparnell
* Placate new javadoc behavior
*
* Revision 1.4 1998/07/22 18:18:41 tparnell
* migration from cs101.util to cs101.*
*
* Revision 1.3 1998/07/21 20:19:17 tparnell
* javadoc bugfix
*
* Revision 1.2 1998/06/03 19:52:01 tparnell
* update from Java 1.0 to 1.1
*
* Revision 1.1 1998/03/13 22:18:21 tparnell
* Import from server crash. I think the src and class files match up.
*
* Revision 1.1 1996/11/18 17:25:06 las
* Added revised SharedWhiteboard support classes. These versions of
* Client and Server supercede the previous ones and are not directly
* backwards compatible. In particular, Server is an instantiable class
* rather than a primarily static one (use RunServer to run it), and
* Client uses StringHandler rather than subclassing to specialize it.
* Line.java just picked up some obscure documentation along the way.
* Otherwise, classes are direct imports from SharedWhiteboard.
*
* Revision 1.4 1996/11/17 22:28:17 las
* Everything compiles (now). Client, Server, ClientDialog, ServerDialog,
* StringHandler, and RunServer need to be moved to cs101.util. But
* first, to test....
*
* Revision 1.3 1996/11/17 21:26:54 las
* Client, ClientDialog writen, not yet tested.
*
*/