There are three essential measurements to consider when locating a swing arm lamp. One is the height of the fixture in relationship to the height of the mattress the 2nd is the extension of the fixture and the 3rd is the adjustment in the shade. It is best to have the specification of the fixture and the bed size (including headboard/platform/frame) when placing the location of the j-box. The j-box is the power source and will determine exactly where the wiring is pulled through the wall. The fixture is then connected to the j-box. Each fixture will have an extension, typically between 18” and up to 29”. The extension determines the spacing between the edge of the mattress/frame and the j-box. I typically center the j-box with the center of the nightstand. Some platform beds can have a very wide frame style so the longer the extensions are very useful.
The best way to determine the height of the j-box is to sit on the mattress and measure from the floor to the top of your shoulder. For a standard frame this is typically between 44” and 46” of the floor. The bottom of the shade should be at your shoulder.