What?
I'm sorry, to me this is like saying there really is no right to free speech. If what you say offends someone - anyone - you no longer have the right to say it.
Sorry judge, my right to free speech is not given to me by you, it's a God given right that you do not have the power to rescind.
The judge didn’t say, “to keep from offending others”; he said, “to prevent ... invading the rights of other students.” Then he specifically said that he did not recognize a “right” to not hear something you didn’t like.
I assume what he had in mind was “invading” another student’s “right” to learn the subjects being taught in school. For example, if one student spend the entire class period screaming obscenities at everyone else, that prevents the educational mission of the school from progressing. In that situation, I think everyone would agree the student should be removed.