Java Reference
In-Depth Information
forward it as their own. Figure 14-8 is the GUI for that program; both this and the main pro-
gram are online in the email directory. Using the JTextAreaWriter , I was able to add a GUI
wrapper to CheckOpenMailRelay , such that console output appears in a window, without
having to change the code to know about JTextArea .
In the constructor of the GUI wrapper, I create a JTextArea and wrap it in a Tex-
tAreaWriter and then a PrintWriter . I pass this PrintWriter to the console program
CheckOpenMailRelay.process() method. That method writes its output to the stream in
addition to assigning standard output and standard error, so we should see anything it tries to
print. Figure 14-8 shows three windows: the program output window (the goal of this whole
exercise), a terminal window from which I copied the IP address (some parts of the text in
this window have been deliberately obfuscated), and another command window in which I
started the GUI program running. The code is shown in Example 14-7 .
Figure 14-8. CheckOpenMailRelayGui in action
Example 14-7. CheckOpenMailRelayGui.java
Search WWH ::




Custom Search