Thanks for writing in to Heathcare Magic!
Most likely you had a hard hit on the scrotum
which has resulted in enough trauma.
The cause of swelling is injury
related inflammation of testis/ rarely a torsion of testis and possibly an accompanying hematoma
Swelling has subsided but the hematoma will take about a month.
If you get restart of pain accompanied by fever
, you must immediately consult a physician because these changes means a hematoma infection.
Otherwise it is self limiting problem.
Wish you a great health!