status messages in display window


I'm interested in displaying custom messages in one of the corners of a VisAD 
display. I have determined several ways to do this, but I'm wondering what the 
most efficient way is.

In particular, it would be nice to be able to update the message without 
triggering a TRANSFORM_DONE event, since my messages will change when 
TRANSFORM_DONE events are received. Of course, I could work around this with 
boolean flags, but would prefer a cleaner approach if one exists.

One way I've found to display custom messages near the "Please wait . . ." 
indicator is to use (abuse?) the exception printing facility. Source code is 

Anyone know of a better/faster/shorter/cleaner way to do this?



import javax.swing.JFrame;

import visad.*;
import visad.java3d.DisplayImplJ3D;

public class DisplayMsgTest {

  public static void main(String[] args) throws Exception {
    DisplayImplJ3D d = new DisplayImplJ3D("display");
    final DataRenderer dr = d.getDisplayRenderer().makeDefaultRenderer();
    d.addDisplayListener(new DisplayListener() {
      public void displayChanged(DisplayEvent e) {
        if (e.getId() == DisplayEvent.TRANSFORM_DONE) {
          String[] msg = {
            "The exception facility can be used",
            "as a nifty status report mechanism"
          for (int i=msg.length-1; i>=0; i--) {
            dr.addException(new VisADException(msg[i]));
          System.out.println("TRANSFORM_DONE: " + System.currentTimeMillis());
    DataReferenceImpl ref = new DataReferenceImpl("ref");
    d.addReferences(dr, ref);

    JFrame f = new JFrame("Exception message test");
    f.setBounds(300, 300, 300, 300);;

    System.out.println("Waiting 10 seconds...");
    while (true) {
      System.out.println("setData: " + System.currentTimeMillis());
      ref.setData(new Real(Math.random()));