Michael, the jBPM Designer can generate process and usertask forms (see docs: http://docs.jboss.org/jbpm/v5.2/userguide/ch10.html#d0e3195). As far as how it does it - the short answer is by inspecting the BPMN2 of your process. If you are interested in details, you can read the code. Good place would be starting here: https://github.com/tsurdilo/process-designer/blob/master/src/main/java/com/intalio/web/server/TaskFormsServlet.java.
Hope this helps.