Package com.gargoylesoftware.base.gui
Class DefaultComponentLoader
java.lang.Object
com.gargoylesoftware.base.gui.DefaultComponentLoader
- All Implemented Interfaces:
ComponentLoader
A default implementation of ComponentLoader that uses reflection
to instantiate components.
- Version:
- $Revision: 1.4 $
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultComponentLoader
(Class clazz) Create a new loader.DefaultComponentLoader
(Class clazz, boolean wrapInJScrollPane) Create a new loader.DefaultComponentLoader
(String className) Create a new loader. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
assertNotNull
(String fieldName, Object object) Throw an Exception if the specified object is null.Load the component.
-
Field Details
-
clazz_
-
wrapInJScrollPane_
private final boolean wrapInJScrollPane_
-
-
Constructor Details
-
DefaultComponentLoader
Create a new loader.- Parameters:
className
- The name of the class that will be used to create the new object. This class must have a public no-arg constructor and must be an instance of java.awt.Component.- Throws:
ClassNotFoundException
- If the class cannot be found.
-
DefaultComponentLoader
Create a new loader.- Parameters:
clazz
- The class that will be used to create the new object. This class must have a public no-arg constructor and must be an instance of java.awt.Component.
-
DefaultComponentLoader
Create a new loader.- Parameters:
clazz
- The class that will be used to create the new object. This class must have a public no-arg constructor and must be an instance of java.awt.Component.wrapInJScrollPane
- If true then the returned component will be a JScrollPane which contains the loaded component.
-
-
Method Details
-
loadComponent
Load the component.- Specified by:
loadComponent
in interfaceComponentLoader
- Returns:
- the loaded component.
- Throws:
Exception
- If something went wrong during the creation of the component.
-
assertNotNull
Throw an Exception if the specified object is null.- Parameters:
fieldName
- The name of the field that we are checking.object
- The value of the field that we are checking
-