ModalityState () { if (myThreadToUse != ThreadToUse.SWING_THREAD) return null; Application application = ApplicationManager.getApplication(); if (application == null) return null; return application.getDefaultModalityState(); }