// adding the stuff to the fram, and making it visibile, etc. frame.getContentPane().add(BorderLayout.CENTER, chatPanel); frame.getContentPane().add(BorderLayout.SOUTH, sendButton); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300,300); frame.setVisible(true);
Ah, thank you, and I should have realized this because as the doc says "Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError()." I hate when the answer was kind of infront of me and I just couldn't see it.
On a side note: Would I really want to remove the try block, because I wrapped it in an Exception (instead of an IOException) and it worked fine? Basically my question is, wouldn't I want to wrap it in some sort of an exception, because if I didn't, and the connection broke (cat chewed the wire or something retarded like that) and I tried to send something, and didn't have a try block around the PrintWriter methods, wouldn't that crash the program or something horrible like that? Then again I'm still noobalicious and could be mistaken
Thanks again. [ September 01, 2005: Message edited by: Nicholas Carrier ]
author and iconoclast
If the connection closes, you won't get an exception of any kind. The methods will simply return without doing anything. You can insert calls to checkError() as the Javadoc says, and deal with the error if you choose. But no, the try block really isn't necessary.