Prev: Array of ArrayLists problem
Next: Arithmetic
From: markspace on 6 Jul 2010 11:34 jc_usernet wrote: > I am thinking along the lines of a static method like > DiagnosticOutput.put( String stringToAppend ) What I would do here is use the logging framework. Make a Handler that writes to a JTextArea. Then you can control writes and even instantiation more easily just by using the normal logging configuration properties. Here's an example. This class is, I believe, thread-safe, although quite simple. class TextAreaHandler extends Handler { private final JTextArea view; public TextAreaHandler( JTextArea view ) { this.view = view; } @Override public void publish( LogRecord record ) { view.append( record.getMessage() ); view.append( '\n' ); } @Override public void flush() { // no-op } @Override public void close() { // possibly dispose the top-level window here } }
|
Pages: 1 Prev: Array of ArrayLists problem Next: Arithmetic |