If you plan to show up in court, it may be best to dress up for the occasion.

A federal judge in Brooklyn, New York on Thursday threw out a complaint by a lawyer alleging a constitutional right to wear jeans and a baseball hat in a courtroom.

Todd Bank, whose office is in Kew Gardens, New York, showed up in a Queens housing court in March 2008 while wearing a button-down shirt, blue jeans, socks, shoes and a baseball hat that read Operation Desert Storm.

Judge Anne Katz told Bank he was dressed inappropriately, and court clerk Jude Albano told him to take the hat off.

Bank sued both, saying his right to free speech and his liberty to dress as he wishes, which he said are guaranteed under the First and Fourteenth Amendments, allowed him to wear the clothing.

Not so, said U.S. District Judge Nicholas Garaufis.

A courtroom is a staid environment where a judge may set reasonable limits on litigants' behavior to enforce commonly shared mores of courtroom civility, he wrote.

He said the case raised no serious dispute, lamenting that the office of New York State Attorney General Andrew Cuomo has now had to expend resources defending the matter.

The judge added, however: When he is not in court, plaintiff is free to express the ideas he wishes to express, and to wear the attire he chooses to wear.

Bank did not immediately return requests for comment. He did not allege discrimination on the basis of the hat's content.

The case is Bank v. Katz, U.S. District Court, Eastern District of New York (Brooklyn), No. 08-1033.