Recently I was reading Swing Hacks by by Joshua Marinacci and Chris Adamson (ISBN: 978-0-596-00907-6). I came across Hack 95: Debug Your GUI which basically recommends building a dialog window containing a JTextArea that has the standard output streams routed to it. I thought this hack could be useful for debugging deployed applications since it makes it very easy for customers to get access to the console output.
The problem with this is that during development I like to look at the console output in Eclipse or from the terminal where I launched the application. So in order to get the standard streams routed to both the the normal standard output and to the debug dialog window I designed a utility class. The utility class redirects the standard streams to a custom OutputStream which then distributes the output to the normal standard output/error and also to any additional registered listeners like a debug dialog window.
Figure 1: Custom Debug Console in Swing
Figure 2: Eclipse Console Output
Subscribe via RSS