public class FormLoader extends Object
FormCreator
to create Swing component instances.
The separation of the file loading and the component creation into two classes
(FormLoader
and FormCreator
) enables you to cache the form model
in memory. Using FormCreator
it's possible to create multiple instances
of a form from one form model.
Modifier and Type | Method and Description |
---|---|
static FormModel |
load(File file)
Loads a form model from the specified file.
|
static FormModel |
load(InputStream in)
Loads a form model from the given input stream.
|
static FormModel |
load(InputStream in,
ClassLoader classLoader)
Loads a form model from the given input stream.
|
static FormModel |
load(String resourceName)
Loads a form model from the specified resource using the default
class loader.
|
static FormModel |
load(String resourceName,
ClassLoader classLoader)
Loads a form model from the specified resource using the specified
class loader.
|
public static FormModel load(String resourceName) throws Exception
ClassLoader.getResourceAsStream(java.lang.String)
to locate and load the form file.resourceName
- The name of the resource containing a form
(e.g. "com/jformdesigner/examples/LoaderExample.jfd").Exception
- See load(InputStream)
for details.public static FormModel load(String resourceName, ClassLoader classLoader) throws Exception
ClassLoader.getResourceAsStream(java.lang.String)
to locate and load the form file.resourceName
- The name of the resource containing a form
(e.g. "com/jformdesigner/examples/LoaderExample.jfd").classLoader
- The class loader.Exception
- See load(InputStream)
for details.public static FormModel load(File file) throws Exception
file
- The file containing a form.Exception
- See load(InputStream)
for details.public static FormModel load(InputStream in) throws Exception
A BufferedInputStream
is used to improve performance.
in
- The input stream. Closed when this method returns.IllegalArgumentException
- If the input stream is null
.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 a FormModel
.Exception
- If an other error occurred when decoding the XML content.public static FormModel load(InputStream in, ClassLoader classLoader) throws MultiException
A BufferedInputStream
is used to improve performance.
in
- The input stream. Closed when this method returns.classLoader
- The class loader used to load classes.IllegalArgumentException
- If the input stream is null
.MultiException
- If a problem occurred when encoding the form model to XML.ClassCastException
- If the root object in the XML content is not a FormModel
.Copyright (C) 2004-2019 FormDev Software GmbH. All rights reserved.