Added a method to check if the current thread is the swing thread.