views:

52

answers:

1

I implementing a EventQueue and get notified when AWTEvents are send. I wait till instances of FocusEvent are send to the dispatchEvent methode.

The FocusEvent by itself does not have a methode to ask if the focus of the component is gained or lost. The methode paramString returns a String in which the information is placed, but i dont want to hack or pars the String. A contains call can give me the answer, but the returnes String is no constant, so it could change in the future.

The paramString methode of FocusEvent is like:

 switch(id) {
      case FOCUS_GAINED:
          typeStr = "FOCUS_GAINED";
          break;
      case FOCUS_LOST:
          typeStr = "FOCUS_LOST";
          break;
      default:
          typeStr = "unknown type";
    }
    return typeStr + (temporary ? ",temporary" : ",permanent") +
        ",opposite=" + getOppositeComponent();

Do you know another solution for this issue.

+2  A: 

What's wrong with "evt.getID()"? It returns FOCUS_LOST or FOCUS_GAINED?

Paul Tomblin
when you want to implement something during the last minutes in the office you sometimes get crazy. Thanks a lot.
Markus Lausberg
@Markus - I know that feeling well. Glad to help.
Paul Tomblin