A 17-year-old boy who has mental health problems and gets fixated on women should be detained in a specialist unit, a judge in the Court of Protection has decided.
Mr Justice Williams heard that a "particular feature" of the teenager's behaviour was that he could become "obsessive" about girls or young women and follow them or bombard them with messages.
He has also threatened people with a knife, started fires at his home, self-harmed and run into busy roads.
The judge said evidence showed that the teenager could not safely stay at home and has made a 12-month "deprivation of liberty" order, under the terms of mental capacity legislation, following an application by council social workers.
Detail of the case has emerged in a ruling published by Mr Justice Williams following a hearing in the Court of Protection, where judges consider issues relating to people who lack the mental capacity to make decisions for themselves, in London.
The judge said the teenager had been adopted aged five after suffering "serious abuse" at the hands of his parents.
"Unfortunately the consequences of the abuse (he) suffered continue to sound now some 12 years later," said Mr Justice Williams.
"(His) behavioural issues are such that it is no longer safe for him at home with his adoptive parents."
The judge added: "He needs intensive support and therapeutic input in order to reduce the risks he faces. This will not be a short-term recess but is likely to take months if not years."
Mr Justice Williams said the teenager, who lacked the mental capacity to make decisions about his care, could not be identified.
He said social services bosses at Buckinghamshire County Council had responsibility for the teenager's welfare.