Documentation
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 .jfd 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
redistributables 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
FormLoader
provides methods to load JFormDesigner .jfd files into in-memory form models.FormCreator
creates instances of Swing components from in-memory form models and provides methods to access components.FormSaver
saves in-memory form models to JFormDesigner .jfd files. Can be used to convert proprietary form specifications to JFormDesigner .jfd files: first create an in-memory form model from your form specification, then save the model to a .jfd file.
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(); } }