Instead of testing the name, you should check whether the thread is the event dispatch thread:
if (EventQueue.isDispatchThread()) {
// do stuff...
}
Note that even though you are using AWT, you can also call
if (SwingUtilities.isEventDispatchThread()) {
// do stuff...
}
and get exactly the same thing.