Sheriff shot judge in courthouse