Java Reference
In-Depth Information
else if (i == '\r' || i >= ' ')
buf.append ((char) i);
}
while (!leave && in.available() > 0
&& buf.length() < 1024);
show (buf.toString());
buf.setLength (0);
}
}
catch (Exception e) {
if (!leave) show (e.toString() + "\r");
disconnect();
}
}
}
/** Class for thread safe appending of information to
the list of incoming data */
class Appender implements Runnable {
String data;
Appender (String data) {
this.data = data;
}
public void run() {
int i0 = data.indexOf ('\r');
//System.out.println ("Adder: cr index is: "+i0);
if (i0 == -1) i0 = data.length();
incoming.replaceItem
(incoming.getItem (incoming.getItemCount() - 1)
+ data.substring (0, i0), incoming.getItemCount()-1);
i0++;
while (i0 <= data.length()) {
int i = data.indexOf ('\r', i0);
if (i == -1) i = data.length();
incoming.add(data.substring (i0, i));
i0 = i+1;
}
}
}
Frame frame = new Frame();
TextField urlField = new TextField ("");
List incoming = new List();
TextField sendField = new TextField();
Button connectButton = new Button ("connect");
Button sendButton = new Button ("send");
Handler handler;
/** Initializes GUI */
Search WWH ::




Custom Search