NEW YORK (AP) -- J.C. Penney, which is struggling with big losses and steep sales declines, could face another challenge: empty shelves.

New York State Supreme Court Judge Jeffrey Oing told Penney's attorneys on Monday that the chain took a risk by ordering towels, cookware and other products from the company that home diva Martha Stewart founded. In fact, Oing said he could force Penney to stop the products from heading to the shelves even as they come off the docks.

"That's the risk your client took," Oing said. "Ultimately, you guys played it out."

The judge's statements came during the start of the third week in a trial that pits J.C. Penney Co. against rival Macy's Inc. over their relationship with Martha Stewart Living Omnimedia Inc. At issue is whether Macy's has the exclusive right to sell some of Martha Stewart branded products such as cookware, bedding and bath.

Macy's has argued that Penney breached its long-standing contract when it signed a deal in December 2011 to open Martha Stewart mini shops in most of its stores this spring. Macy's, which has been the exclusive carrier of some Martha Stewart products including towels and pots since 2007, is trying to block Penney from selling those products. It also wants to stop Martha Stewart from providing any designs to Penney -- whether or not it carries the Martha Stewart label.

Last July, Macy's won a preliminary injunction against Martha Stewart Living that would prevent it from selling housewares and other exclusive products at Penney. In August, the judge granted permission for Penney to open Martha Stewart shops as long as they do not sell items under the exclusive contract with Macy's..

But Penney took a more liberal interpretation of the preliminary ruling. Penney said it plans to sell products that are part of Macy's exclusive agreement in May. The goods will be branded under JCP Everyday, a new brand reserved for the home diva's merchandise. Penney also plans to sell products like curtains and stationery that are not a part of the exclusive Macy's contract under the label "Martha."