The free AirTrain connects all the terminals and runs about every 5 mins, so you'll be able to quickly change terminals in a few minutes. I always fly out of T8 or T9, though, so don't know what type of security lines you'd have in other terminals at JFK.