Methods Summary |
---|
public java.net.URLStreamHandler | createURLStreamHandler(java.lang.String protocol)
if (protocol.equalsIgnoreCase("chargen")) {
return new chargenURLStreamHandler();
}
else {
return null;
}
|
public void | init()
URL.setURLStreamHandlerFactory(this);
setLayout(new BorderLayout());
theText = new TextArea();
add("Center", theText);
String s = "chargen://sunsite.unc.edu/";
try {
theServer = new URL(s);
dis = new DataInputStream(theServer.openStream());
}
catch (MalformedURLException e) {
theText.setText("Error: Could not handle URL " + s);
}
catch (IOException e) {
theText.setText("Error: Could not open connection to " + s);
theText.appendText("There may not be a chargen server running" +
"on this host or network connections may be disallowed.");
}
Thread t = new Thread(this);
t.start();
|
public static void | main(java.lang.String[] args)
Frame f = new Frame("chargen applet");
f.resize(300, 300);
f.move(50, 50);
chargenApplet cg = new chargenApplet();
f.add("Center", cg);
cg.init();
f.show();
cg.start();
|
public void | run()
try {
String theLine;
if (dis != null) {
while ((theLine = dis.readLine()) != null) {
theText.appendText(theLine + "\r");
}
}
}
catch (IOException e) {
}
|