Runtime Library

Note: If you use the Java code generator, you don't need this library.

The open-source (BSD license) runtime library allows you to load JFormDesigner XML files at runtime within your applications. Turn off the Java code generation in the Preferences dialog or in the Project settings if you use this library.

You'll find the library jfd-loader.jar in the redist folder (or plug-in) of the JFormDesigner installation; the source code is in jfd-loader-src.zip and the documentation is in jfd-loader-javadoc.zip.

The API documentation is also available here: doc.formdev.com/jfd-loader/.

Classes

Example

The following example demonstrates the usage of FormLoader and FormCreator. It is included in the examples distributed with all JFormDesigner editions.

public class LoaderExample
{ private JDialog dialog;
 
public static void main(String[] args) { new LoaderExample();
}   LoaderExample() { try { // load the .jfd file into memory FormModel formModel = FormLoader.load( "com/jformdesigner/examples/LoaderExample.jfd");
 
// create a dialog FormCreator formCreator = new FormCreator(formModel);
formCreator.setTarget(this);
dialog = formCreator.createDialog(null);
 
// get references to components JTextField nameField = formCreator.getTextField("nameField");
JCheckBox checkBox = formCreator.getCheckBox("checkBox");
 
// set values nameField.setText("enter name here");
checkBox.setSelected(true);
 
// show dialog dialog.setModal(true);
dialog.pack();
dialog.show();
 
System.out.println(nameField.getText());
System.out.println(checkBox.isSelected());
System.exit(0);
} catch(Exception ex) { ex.printStackTrace();
} }   // event handler for checkBox private void checkBoxActionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(dialog, "check box clicked");
}   // event handler for okButton private void okButtonActionPerformed() { dialog.dispose();
} }