Package com.jformdesigner.runtime
Class FormLoader
- java.lang.Object
-
- com.jformdesigner.runtime.FormLoader
-
public class FormLoader extends Object
Loads the form model from a JFormDesigner .jfd file into memory. UseFormCreatorto create Swing component instances.The separation of the file loading and the component creation into two classes (
FormLoaderandFormCreator) enables you to cache the form model in memory. UsingFormCreatorit's possible to create multiple instances of a form from one form model.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FormModelload(File file)Loads a form model from the specified file.static FormModelload(InputStream in)Loads a form model from the given input stream.static FormModelload(InputStream in, ClassLoader classLoader)Loads a form model from the given input stream.static FormModelload(String resourceName)Loads a form model from the specified resource using the default class loader.static FormModelload(String resourceName, ClassLoader classLoader)Loads a form model from the specified resource using the specified class loader.
-
-
-
Method Detail
-
load
public static FormModel load(String resourceName) throws Exception
Loads a form model from the specified resource using the default class loader. UsesClassLoader.getResourceAsStream(java.lang.String)to locate and load the form file.- Parameters:
resourceName- The name of the resource containing a form (e.g. "com/jformdesigner/examples/LoaderExample.jfd").- Returns:
- The form model.
- Throws:
Exception- Seeload(InputStream)for details.
-
load
public static FormModel load(String resourceName, ClassLoader classLoader) throws Exception
Loads a form model from the specified resource using the specified class loader. UsesClassLoader.getResourceAsStream(java.lang.String)to locate and load the form file.- Parameters:
resourceName- The name of the resource containing a form (e.g. "com/jformdesigner/examples/LoaderExample.jfd").classLoader- The class loader.- Returns:
- The form model.
- Throws:
Exception- Seeload(InputStream)for details.
-
load
public static FormModel load(File file) throws Exception
Loads a form model from the specified file.- Parameters:
file- The file containing a form.- Returns:
- The form model.
- Throws:
Exception- Seeload(InputStream)for details.
-
load
public static FormModel load(InputStream in) throws Exception
Loads a form model from the given input stream. Use this method if you want read a form e.g. from a database.A
BufferedInputStreamis used to improve performance.- Parameters:
in- The input stream. Closed when this method returns.- Returns:
- The form model.
- Throws:
IllegalArgumentException- If the input stream isnull.IOException- If an error occurred when reading from the input stream.SAXParseException- If an error occurred when parsing the XML content.ClassNotFoundException- If a class used in the XML content is not found.ClassCastException- If the root object in the XML content is not aFormModel.Exception- If an other error occurred when decoding the XML content.
-
load
public static FormModel load(InputStream in, ClassLoader classLoader) throws MultiException
Loads a form model from the given input stream. Use this method if you want read a form e.g. from a database.A
BufferedInputStreamis used to improve performance.- Parameters:
in- The input stream. Closed when this method returns.classLoader- The class loader used to load classes.- Returns:
- The form model.
- Throws:
IllegalArgumentException- If the input stream isnull.MultiException- If a problem occurred when encoding the form model to XML.ClassCastException- If the root object in the XML content is not aFormModel.- Since:
- 1.0.1
-
-