A Scarborough High School honor student appeared in juvenile court Monday to deny charges that he broke into the home of a 47-year-old Scarborough man last week and shot him twice as he slept in his family room.

Matthew Gwyer, 17, said nothing during the detention hearing at the Cumberland County Courthouse in Portland, leaving his defense attorney, Edwin Chester, to enter denials to charges of attempted murder, elevated aggravated assault and felony burglary in the shooting of Bruce Glidden in his Ash Swamp Road home on Jan. 18.

Judge E. Mary Kelly ordered that Gwyer be detained at Long Creek Youth Development Center in South Portland and undergo a psychological exam by the State Forensic Service.

No details emerged during the court hearing about a potential motive for the shooting. Gwyer’s parents and Glidden’s family sat quietly in the courtroom and left swiftly afterward without commenting.

Daniel Warren, the attorney who represents Gwyer’s parents, Drew and Maura Gwyer, spoke on their behalf outside the courthouse after the hearing. Reached by phone afterward, Maura Gwyer declined to comment.

Warren said he has known the Gwyer and Glidden families for years, and described them as good families. He said Matthew Gwyer and the Gliddens’ two teenage children, a girl and a boy, attend Scarborough High School together. Warren didn’t know how well Matthew Gwyer and the Glidden children knew each other, but said it is a relatively small school, about 1,100 students total, and they likely traveled in some of the same circles since they are all involved in athletics.

“The family is distraught. This is a tragedy for everyone involved,” Warren said on behalf of the Gwyers.

Warren said Matthew Gwyer is a high school senior who had recently been inducted into the National Honor Society, had applied to colleges and plays basketball and baseball.

“At this point, we’re still trying to get a handle on what happened,” Warren said.

Scarborough High officials would not comment Monday. The superintendent posted a news release on the school system website Friday saying the district would not comment on the shooting and referring all questions to the Scarborough Police Department.

Bruce Glidden and his two children also came to the courthouse Monday, but did not attend the hearing. Glidden’s wife, Amy Glidden, and her sister attended the hearing, but said nothing as they left. Bruce Glidden did not respond to an email sent later Monday.

Assistant District Attorney Christine Thibeault, who heads the juvenile division of the prosecutor’s office, said it is too soon to say whether she will seek to charge Matthew Gwyer as a juvenile or an adult.

“We’re requesting a psychological evaluation from the State Forensic Service to help us figure that out,” Thibeault said.

The charges against Gwyer would be considered Class A felonies if he was prosecuted as an adult, each charge punishable by up to 30 years in prison. If prosecuted as a juvenile, Gwyer could be sent to Long Creek until he turns 21, at a maximum.

The identities of juveniles charged with crimes are generally confidential, but the name of a juvenile charged with a felony becomes public once the case begins to make its way through the court system.

Whether Gwyer is treated as an adult is not entirely the decision of the district attorney’s office. Prosecutors would have to file a motion to bind the case over to adult court, which Matthew Gwyer could contest. If contested, the decision would ultimately be up to a judge.

Thibeault declined to say what evidence police have compiled against Matthew Gwyer so far or what animosity he might have toward any member of the Glidden family.

“The investigation is still ongoing, and I wouldn’t comment anyway on the facts of the charges,” she said.

The only new detail that Thibeault would reveal is that a 9 mm handgun was used to shoot Bruce Glidden, the same type of weapon seized by police from Matthew Gwyer’s vehicle when they arrested him Friday.

Scarborough police had received a report of a suspicious vehicle in the driveway of a home on Pleasant Hill Road early Friday, a day after they released a description of a silver-colored vehicle that was in the area of Bruce Glidden’s Ash Swamp Road residence around 1:30 a.m. on Jan. 18.

An officer responding to the suspicious vehicle report saw a gray Honda Ridgeline pickup truck on Black Point Road being driven without taillights and pulled the Honda over, police said. They arrested Matthew Gwyer, who was alone in the vehicle, after discovering the handgun inside.

On the night of the shooting, Glidden was sleeping in the family room. His wife and two children were sleeping elsewhere in the house and were not hurt or threatened during the attack.

Glidden, an owner of Glidden Roofing Corp. in Scarborough, was hospitalized at Maine Medical Center in Portland for about two days before being released.

The windows of a car owned by the Gliddens were broken with an object, not by gunfire, at the time of the shooting, police said. This week, police said investigators had heard that a window on Glidden’s work truck had been smashed about a week before the shooting, but no police report was made at the time.

Drew Gwyer, Matthew’s father, is semiretired after serving 23 years in the Navy. He has been active in Scarborough as a critic of property tax rates in the town. Maura Gwyer has been active as a board member and an officer in the Higgins Beach Association.

Chester, the attorney, was appointed to represent Matthew Gwyer for the detention hearing, and it wasn’t clear Monday whether the Gwyer family would hire him to continue representing their son.

Chester declined to argue against detention at the hearing and reserved the right for himself or another attorney to argue for Matthew Gwyer’s release from Long Creek at a later date. Chester met with Matthew Gwyer at Long Creek over the weekend and said he’s coping with the new environment.

“I think it’s hard for anyone to go into Long Creek for the first time. I think he’s doing as well as can be expected,” Chester said.

A petition filed by prosecutors to bring the charges against Matthew Gwyer provided few facts, other than basic details such as his birthday, his height of 6 feet, 4 inches, and his weight, 145 pounds. The one-page petition was the only publicly viewable document in his juvenile case file.

Matthew Gwyer is next due to appear in court March 24, two days before his 18th birthday.