Java Reference
In-Depth Information
} catch (IOException ie) {
System.out.println("Error:" + ie.getMessage());
System.exit(-1);
}
}
//creates the thread and shows it
public void show() {
Runnable runner = new FrameDisplay();
EventQueue.invokeLater(runner);
}
private class FrameDisplay implements Runnable {
public void run() {
frame.setVisible(true);
}
}
}
In short, this helper simply reads the image that the client class saved off at the specified loc-
ation and adds it to a frame, which it then displays in a runnable.
Running the program prints the following output:
Xml Response: <?xml version='1.0' encoding='utf-8'?><mascot>Xml
Duke</mascot>
Got XML. Now getting HTML...
Html Response: <html><h1>Html Duke</h1></html>
Now getting image...
Response Size=13715
Response Type=Content-Type: image/gif
All done.
Once the text representations are printed, the program creates a JFrame and shows the image
you received as the GIF representation response in the window to prove that the client got it
intact. The screenshot is shown in Figure 8-2 .
Search WWH ::




Custom Search