Unfortunately, you can't prevent people from suing you, no matter how crazy the claim. What you can do, though, is prevent them from succeeding on their claims. However, there's being right, and there are the practicalities of the situation. If it would cost you more to hire an attorney than to pay the painter for what he says is owed, stop for a minute and think about whether you really want to fight him "on principle."

First step, though, is to at least consult with a litigation attorney to get clear on your defenses to the action (it sounds like you have a few) and to see whether there are any claims you might be able to bring against the painter.