I would certainly think that stress can play a role in making nightmares more frequent. I'm wondering if you have told your doctor about them, especially since you are supposedly taking a med to help. Maybe you need a stronger dose or a different med.
I hope things go well with the court session and your nightmares will diminish soon!