I ran a brain-in-a-jar fight just last week. I had the same concern as you - how to make the brain resistant enough to certain attacks to make it a challenging opponent. Fortunately, as I worked on the encounter location - an "operating theatre" full of hanging chains with manacles and spikes attached - I decided on the basic nature of the brain. It was going to be an expert telekineticist, manipulating the chains in the room to attack the PCs, using telekinetic powers to attack the PCs, and assist its allies. Voila - the brain surrounds itself with a telekinetic force field that deflects force and weapon attacks. In mechanical terms, it had resist 10 force (minimising magic missile damage) and an immediate interrupt at-will power to gain a +4 bonus to a defence targeted by a weapon attack - so it was able to deflect one ranger's arrow per round. (Stats at the foot of this message).
Brains-in-jars are highly intelligent and charismatic monsters. They're likely to be significant opponents, not just hanging around for their jars to be smashed and their squishy brains stomped on. So, why is your brain-in-a-jar in a swamp? What's its schtick?
See, to me, brain-in-a-jar in a swamp makes me think of mad scientist's experiment gone wrong (the mad scientist's lab, of course, being underneath the old mansion slowly rotting away beside the bayou). What do mad scientists use animate dead matter? Lighting, of course! And what lives in a swamp and likes lightning? Shambling mounds, of course!
Combine that with Lancelot's "Krang" idea, and you have a concept. A brain-in-a-jar embedded deep in the rotting vegetable body of a shambling mound. Sure, it's now stuck on the ground, but you've now got yourself a melee controller concept, not a ranged controller concept. Surround the thing with an electrical aura that does lightning damage. Or have an immediate action that "zaps" an enemy attacking the brain-shambler in melee, doing lighting damage and pushing it back one or two squares. 3-square reach plus slide on the tentacle attacks. Of course, it can also dish out the ranged damage, with an encounter or rechargeable lighting bolt attack. Etc.
Also, what are the ranged attacks you want to avoid? Then work out how to avoid that damage consistent with the monster concept. For example, if the wizard PC always pounds things with ranged fire attacks, maybe the brain-shambler is coated in a wet, sticky ooze that's fire resistant.
If the archer ranger is always reducing things to pincushions, how about the brain-in-a-jar has a psychic ability that makes it difficult for enemies to focus on - manifesting, in mechanical terms, in an inability for it to be marked, quarried, subject to warlock's curse, paladin's divine challenge etc. This could be a power (e.g. immediate interrupt, i.e. only 1/round), or an aura (i.e. limited radius), or just a trait. The key is that you don't prevent the PCs from attacking the brain, it's just that their attacks are hampered and they don't get all the additional damage or benefits that come from their special "focus on that guy" ability. (I've used this ploy twice on solo monsters IMC, over about 18 months of play. It's best not to over-use it, because it can annoy players, but if used judiciously, can be quite fun for them).
Cheers, Al'Kelhar
Chained brain in a jar Level 12 Elite Controller
Medium natural animate XP 1400
HP 246; Bloodied 123 Initiative +7
AC 26; Fort 24; Ref 25; Will 24 Perception +9, darkvision
Resist 10 force
Saving Throws +2 Action Points 1
Speed fly 6 (hover); see chained to the spot
TRAITS
Chained to the spot
The brain’s jar is tethered to an immovable shaft by a 5-foot length of chain. The shaft is placed 5 feet from the ceiling in the centre of the room. The brain cannot move, whether willingly or forcibly, more than 1 square from this point, and cannot be brought to the ground until its chain is cut or the shaft is deactivated.
STANDARD ACTIONS
Telekinetic thrust (force) ♦ At-will
Attack: Ranged 10 (one creature); +15 vs. Fortitude
Hit: 3d6+5 force damage and the brain slides the target 1 square.
Domination ♦ Recharge 5+
Attack: Ranged 10 (one creature); +15 vs. Will
Hit: The target is dominated (save ends).
Telekinetic chain ♦ At-will
Effect: The brain telekinetically manipulates one of the hanging chains in the room to flay and strangle a nearby creature.
Attack: Melee 1 centred on a hanging chain in the room (one creature); +15 vs. Reflex
Hit: 3d6+5 damage and the target is restrained (until escape).
MOVE ACTIONS
Helpful shove ♦ At-will
The brain slides one ally within 10 squares 1 square.
MINOR ACTIONS
Strangling chains ♦ At-will, 1/round
Each creature restrained by a telekinetic chain attack takes 10 damage.
TRIGGERED ACTIONS
Deflection field ♦ At-will
Trigger: The brain would be hit by a weapon attack.
Effect (immediate interrupt): The brain gains a +4 bonus to the defence targeted by the attack.
Death rattle ♦ Encounter
Trigger: The brain is reduced to 0 hit points.
Effect (free action): The brain makes a telekinetic chain attack against each enemy in the room that is not currently restrained by a chain, and then uses its strangling chains power.
Skills Arcana +16, Bluff +15, Diplomacy +15, Intimidate +15
Str 12 (+7) Dex 12 (+7) Wis 16 (+9)
Con 19 (+10) Int 21 (+11) Cha 19 (+10)
Alignment Evil Languages Common, telepathy 10
Equipment Immovable shaft