In old gun fights (which just don't happen anymore), shots were likely to come from behind (so, they intersect the pilot) or the top (so, through the canopy if they're hitting the instruments). This has to do with the orientation both planes are probably in if one is shooting at the other. Go back farther and you get shots from the front, not from fighters (head-ons are very difficult to pull off outside of videogames) but from bomber tail gunners - very old planes from WWII even had bulletproof glass in front of the pilot for this reason. If the F35 has gotten into a gunfight, the pilot has fucked up, it's not a dogfighter and wasn't designed to be one.
Even nowadays, if the missile or flak pops next to the cockpit and has managed to damage the instruments, there is a very strong chance the shrapnel has also hurt the pilot to the point that they're not flying home that day. This is the most likely way for the F-35 to be damaged in the modern era.
There are obviously scenarios where the instrument panel gets damaged but the pilot is okay, but it's such a low probability scenario that they likely deemed it to be less harmful than the benefit they foresee in a glass cockpit.