Java Reference
In-Depth Information
/** Set up user interface */
public MidpTerminal() {
uriField.addCommand (okCmd);
uriField.addCommand (abortCmd);
uriField.setCommandListener(this);
sendField.addCommand (okCmd);
sendField.addCommand (abortCmd);
sendField.setCommandListener(this);
incoming.addCommand (connectCmd);
incoming.addCommand (sendCmd);
incoming.setCommandListener(this);
incoming.append ("", null);
}
/** Set display to the URI dialog */
public void startApp() {
display = Display.getDisplay (this);
display.setCurrent (uriField);
}
/** Shows the given string by appending it to the
list with respect to contained line breaks. */
public void show (String data) {
int i0 = data.indexOf ('\r');
if (i0 == -1) i0 = data.length();
incoming.set
(incoming.size()-1,
incoming.getString (incoming.size() - 1)
+ data.substring (0, i0), null);
i0++;
while (i0 <= data.length()) {
int i = data.indexOf ((char) 13, i0);
if (i == -1) i = data.length();
incoming.append (data.substring (i0, i), null);
i0 = i+1;
}
}
/** Performs the action associated with the given command
like showing dialogs, opening the connection or sending
a string */
public void commandAction (Command c, Displayable d) {
try {
if (c == connectCmd)
display.setCurrent (uriField);
else if (c == sendCmd && handler != null)
display.setCurrent (sendField);
else if (c == abortCmd)
display.setCurrent (incoming);
else if (c == okCmd) {
display.setCurrent (incoming);
Search WWH ::




Custom Search