Package com.gargoylesoftware.base.gui
Class DefaultComponentLoader
- java.lang.Object
-
- com.gargoylesoftware.base.gui.DefaultComponentLoader
-
- All Implemented Interfaces:
ComponentLoader
public class DefaultComponentLoader extends java.lang.Object implements ComponentLoader
A default implementation of ComponentLoader that uses reflection to instantiate components.- Version:
- $Revision: 1.4 $
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class
clazz_
private boolean
wrapInJScrollPane_
-
Constructor Summary
Constructors Constructor Description DefaultComponentLoader(java.lang.Class clazz)
Create a new loader.DefaultComponentLoader(java.lang.Class clazz, boolean wrapInJScrollPane)
Create a new loader.DefaultComponentLoader(java.lang.String className)
Create a new loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assertNotNull(java.lang.String fieldName, java.lang.Object object)
Throw an Exception if the specified object is null.java.awt.Component
loadComponent()
Load the component.
-
-
-
Constructor Detail
-
DefaultComponentLoader
public DefaultComponentLoader(java.lang.String className) throws java.lang.ClassNotFoundException
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:
java.lang.ClassNotFoundException
- If the class cannot be found.
-
DefaultComponentLoader
public DefaultComponentLoader(java.lang.Class clazz)
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
public DefaultComponentLoader(java.lang.Class clazz, boolean wrapInJScrollPane)
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 Detail
-
loadComponent
public java.awt.Component loadComponent() throws java.lang.Exception
Load the component.- Specified by:
loadComponent
in interfaceComponentLoader
- Returns:
- the loaded component.
- Throws:
java.lang.Exception
- If something went wrong during the creation of the component.
-
assertNotNull
protected final void assertNotNull(java.lang.String fieldName, java.lang.Object object)
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
-
-