Pull the bed out from the wall so you can fit the door behind it. Place the door behind the bed on its side. Make sure it is centered. If it is too long for your liking, mark the places where you want to cut it using a pencil, then cut off the excess with a power saw.
Remove the doorknob or handle with a screwdriver. Remove the hinges, if they are still attached. Apply wood putty to the screw holes using a putty knife and let it dry. You do not need to fill the doorknob hole, if there is one. Just use that side on the bottom of the headboard and it will be covered by the mattress.
Sand the door with 120-grit sandpaper. Follow the grain of the wood. Wipe the dust off with a tack cloth. Stand the door on its side with the doorknob hole side nearest the floor.
Measure the length of the door. Cut a piece of decorative chair rail molding to this length. Apply a bead of wood glue to the top side of the door and press the molding into the glue. Let it dry for 24 hours.
Drive finishing nails through the top of the molding and into the door with a hammer. Place one nail every 12 inches.
Paint the headboard and molding with an interior primer. Follow the grain of the wood and apply a thin layer. Let it dry according to the package directions.
Paint the headboard with a coat of interior latex paint in a semi-gloss finish, following the wood grain. Let the first coat dry, then apply a second coat if you want a darker finish. You can also paint a design on the door, or paint the panels a contrasting color.
Use an electric drill to attach two D-rings to the back of the headboard. Place one on each side, 3 inches in from the edge and 3 inches under the molding. Attach a length of picture hanging wire to the two hooks.
Drill a pilot hole in the wall, into a stud, at the height you want the headboard to hang. Screw a heavy-duty picture hook into the hole. The hook should be rated to bear at least 100 pounds. Lift the headboard into place and hang the wire from the hook.
Measure the distance between the floor and the bottom of the door. Cut three pieces of 2-by-2 lumber to this length, and use screws to attach them to the wall below the door, one in the center and one at each end, in far enough that they won’t be visible when the bed is pushed against the headboard. These boards will help steady the door and support its weight.