His behaviour is such that if anyone else did or said what he is saying about the judge they would go to prison for contempt of court.
Perhaps the fact this is NOT happening is the reason Trump carries on.
In schools we give choices to children regarding their behaviour, reward good behaviour but issue interventions / sanctions for negative behavior.
However you have to follow through on both, so if a child is told they will miss playtime they should do.
In the case of trump, constant threats of prison, and not following through is just empowering him to keep offending and insulting everyone.