A 14-year-old boy was charged today with opening fire at an eighth-grade graduation dance with the theme "I Had the Time of My Life." A science teacher was killed, one pupil was shot in the foot and another pupil and a teacher were grazed.

Andrew Wurst, a pupil at Parker Middle School, shot teacher John Gillette on a patio outside a banquet hall, walked inside and fired several more shots, left the building through a rear exit and was arrested shortly thereafter, police spokesman Mark Zaleski said.

Teenagers were dancing to the last song -- "My Heart Will Go On," from the movie "Titanic" -- when the first of several booms rang out Friday night at Nick's Place, near Edinboro about 100 miles north of Pittsburgh.

Sobbing girls in satin dresses and terrified boys in neckties huddled outside the hall. Some hid in a closet.

Adam Sarren, 15, said the shots sounded like a cap gun.

"It was pretty horrible. It was like a nightmare," he said. "We were all scared and crying and praying."

A month ago, Wurst joked about killing people and then committing suicide, according to two boys who described themselves as friends of Wurst. Triston Lucas, 14, and Ben Mills, 13, said they did not take him seriously.

"He'd laugh when he said it. You couldn't really take him serious," Lucas said.

Both boys, who attended counseling sessions at the school today, said Wurst did not know Gillette, 48. Wurst never said he planned to kill at the dance, nor had he identified any targets, the boys said.

Gillette, a teacher for 27 years who had organized the dance, was shot in the head.

Two 14-year-old boys were wounded by gunfire; one was grazed across the abdomen and the other shot in the foot. Both were treated at a hospital and released. A female teacher was grazed by a bullet and did not need medical treatment.

Wurst, who carried a .25-caliber handgun registered to his father and a small amount of marijuana, was caught in a field behind the hall just after the shooting by Nick's Place owner James Strand, who carried a shotgun.

Wurst, of nearby McKean, was charged as an adult with criminal homicide and three counts each of aggravated assault and reckless endangerment, as well as drug and gun charges. He was jailed without bond.

School officials did not know what motivated the shooting.

Lucas and Mills said Wurst had a troubled home life and combative parents. They said he had recently argued with his parents over his poor grades.

"I want to talk to him and see what he was thinking before I decide I hate him," Mills said.

Sarren, who said he knew Wurst, described him as a loner who never smiled and dressed sloppily with untucked T-shirts and untied shoes. He said he often wore the same pants for several days in a row.

"He looked like he was dead. He never had his eyes all the way open," Sarren said. "I never liked him at all."

Gillette was a teacher and student council adviser, said his neighbor, high school principal Donald Ickes. He was also a former high school football coach.

"The sad part of this whole thing is I don't have any answers," Therese Walter, superintendent of the General McLane School District, said in a statement outside the school today. "We lost John because he was doing what his life was about."

In the past six months, four students and a teacher were fatally shot at a middle school in Jonesboro, Ark.; three students were killed in a shooting at a high school in West Paducah, Ky., and two students were killed and seven wounded at a high school shooting in Pearl, Miss.

"Too many of us believe that violence is unique to urban areas. The tragedy Friday in Edinboro proves that belief false," said David Gondak, president of the Pennsylvania State Education Association. CAPTION: Andrew Wurst, 14, is led from a court building in McKean, Pa., after he was charged in a shooting spree at a school event that left a teacher slain. CAPTION: Parents and students hug outside Parker Middle School near Edinboro, Pa., before they enter the school for a special counseling session a day after shooting.