There is a difference between fear and panic, and those that understand and accept fear generally will not panic.
Fear is natural, and may or may not exist in a given situation. Fear is natures way of preparing our body to fight, or get out of dodge. Fear is good.
Panic is not good.
The key item was to have a plan. To have a plan means you have to have given the situation some thought beforehand.
Generic plans of action, rehearsed movements, the acceptance of fear, and a practiced mindset are the keys to eliminating panic.
Good SA will allow you to develop a simple course of action based on any given situation and generally involves fight, flight, or fight in order to flee. Rehearsed movements involve simply practicing the movements (ie, training) you will use to execute your plan, be it with or without a weapon. The acceptance of fear will allow you to recognize and adjust to your bodies physiological "boost", and, combined with a practiced mindset, will allow you to function until you get "settled in" to your excited state.
To better handle stress, ie fear, it is important to practice under stress, be it in competition, force on force, sparring, etc... The type of stress isn't as important as you would think simply because you are practicing working THROUGH the stress, and once you develop the mindset, you can pretty much maintain your focus through ANY stress despite fear. You will learn that the worse part of fear and stress takes place prior to your actions, and that once you begin your course of action, you get used to the stress and fear and focus on what you are physically doing, be it shooting, or whatever.
Bottom line: Don't be afraid of fear, maintain good SA and always have a generic plan, PRACTICE to develop some muscle memory, PRACTICE to develop a focused mindset, and lastly, train using some type of stressor, and up the ante from time to time.