Java Reference
In-Depth Information
Listing 6.4 MidpChat.java—A MIDP Chat Client Using the HTTP Protocol to
Communicate with the Server
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.util.*;
import java.io.*;
public class MidpChat extends MIDlet implements CommandListener {
List list = new List ("MidpChat", Choice.IMPLICIT);
TextBox text = new TextBox ("Chat Text", "", 100, TextField.ANY);
int count = -1;
Timer timer;
String host = "http://localhost:8080";
String nick = "guest";
Display display;
Command write = new Command ("Write", Command.OK, 1);
Command submit = new Command ("Submit", Command.OK, 1);
Command cancel = new Command ("Cancel", Command.BACK, 1);
class RefreshTask extends TimerTask {
public void run() {
if (display.getCurrent() == list)
transfer (null);
}
}
class ConfigForm extends Form implements CommandListener {
TextField hostField =
new TextField ("Host:", host, 50, TextField.ANY);
TextField nickField =
new TextField ("Nickname:", nick, 50, TextField.ANY);
Command connectCommand = new Command ("Connect", Command.OK,
1);
Command abortCommand = new Command ("Abort", Command.BACK, 1);
 
Search WWH ::




Custom Search