I'll preface by saying I am categorically opposed to using electric shock to train dogs.
By "electric fence", do you mean the 'invisible' fence, or a 'hot wire' around a physical fence?
Invisible fences are generally not a good choice. Primarily, they do not keep other animals or people (especially kids) out of your yard, which puts your dog at risk, and puts you at risk for a lawsuit should the dog bite something/someone that comes into their yard. (There was just an uproar recently when a "big" dog (really it was medium-sized) severely injured a small dog that was walking with its owner, unleashed, at night and ran into the big dog's yard; despite the fact that the big dog never left its own property, despite the fact that the big dog was legally contained, despite the fact that the small dog's owner was in violation of the leash laws, the public outcry was to punish the big dog and his owner. There have been other similar instances with children, as well, wandering in to invisibly-fenced yards (different big dogs).)
Secondly, many dogs - and Boxers are quite prone to this - will ignore the pain of the shock if there's something they really want on the other side of the fence line, and will run right through it. They will not, however, ignore the pain to cross the fence line to get back into the yard. So the fence may not keep your dog in the yard, but it will usually keep him out of it. Some dogs are so traumatized by the shocks they receive during the training process that they refuse to go into the yard at all. There are some cases of collars malfunctioning and continuously shocking the dog, and many cases of the batteries in the collar dying and not being replaced, so the dog is free to roam. (Some dogs also can tell when the shocking collar is on, and know that if it's not, they don't have to stay in the yard.)
Honestly, if you take the time to train the dog to the invisible fence the proper way, you can train the dog to stay in the yard without resorting to shocking it, and so can save your money.
If you're talking about a hot wire on a physical fence, then I see no need for one. There are many ways to deal with digging or jumping without resorting to using electric shock on the dog.
As far as training collars (and I'm assuming you mean electric shock training collars, here), I can think of only a very few specific situations in which they may possibly be warranted, and then only as a last resort, and only if used by a highly experienced professional. Most of the time, with proper training and consultation, it would never get to that point.