As some others have mentioned, I try and pretend that there is no opponent, only the ball I am playing. This helps me to focus on the ball throughout the match and not worrying about what my opponent is doing.
Also, when I find myself getting negative in my head I try and say positive things out loud. Saying them out loud is key for me to stop the negative thinking. ( I don't say them so loud everyone can hear, just loud enough for me.)