Java Reference
In-Depth Information
if (d == sendField && handler != null) {
handler.out.write
(sendField.getString().getBytes());
handler.out.write ('\r');
handler.out.write ('\n');
handler.out.flush();
sendField.setString ("");
}
else if (d == uriField) {
disconnect();
handler = new Handler (uriField.getString());
handler.start();
}
}
}
catch (Exception e) {
show (e.toString());
disconnect();
}
}
public void pauseApp() {
}
public void disconnect() {
if (handler != null) {
handler.leave = true;
show ("disconnected!\r");
try {
handler.connection.close();
handler.in.close();
handler.out.close();
}
catch (IOException e) {
}
handler = null;
}
}
public void destroyApp (boolean unconditional) {
disconnect();
}
}
Listing 6.3 PdapTerminal.java—The PDAP Terminal Application for Using Different
Protocols in the Same Application
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import java.awt.*;
import java.awt.event.*;
public class PdapTerminal extends MIDlet implements ActionListener {
/** The Handler class cares about establishing the connection and
 
Search WWH ::




Custom Search