Vortex-lattice formation and melting in a nonrotating Bose-Einstein condensate