Package net.sf.jguiraffe.gui.forms
Interface ComponentHandler<T>
-
- Type Parameters:
T
- the data type used by this component handler
- All Known Subinterfaces:
CompositeComponentHandler<T,S>
,ListComponentHandler
,ProgressBarHandler
,StaticTextHandler
,TableHandler
,TextHandler
,TreeHandler
- All Known Implementing Classes:
AbstractCompositeComponentHandler
,AbstractRadioButtonHandler
,ComponentHandlerImpl
,DefaultRadioButtonHandler
public interface ComponentHandler<T>
Definition of an interface for accessing GUI components independently from their type.
This interface represents a Java GUI widget like a text field or a checkbox. There will be concrete implementations for real components, which implement data exchange.
The form framework uses implementations of this interface to transfer data from and to GUI components. The details of this data transfer are hidden by concrete implementations. This makes it possible for instance to read a complete form and store the entered data in a bean.
- Version:
- $Id: ComponentHandler.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
getComponent()
Returns a reference to the real component that is wrapped by this component handler.T
getData()
Returns the data of the wrapped component.Object
getOuterComponent()
Returns the outer most component, which is the component to be added to the enclosing container.Class<?>
getType()
Returns the data type used by this component.boolean
isEnabled()
Returns a flag whether this component is enabled.void
setData(T data)
Sets the data of the wrapped component.void
setEnabled(boolean f)
Allows to set the enabled flag.
-
-
-
Method Detail
-
getComponent
Object getComponent()
Returns a reference to the real component that is wrapped by this component handler.- Returns:
- the underlying component
-
getOuterComponent
Object getOuterComponent()
Returns the outer most component, which is the component to be added to the enclosing container. It may sometimes be necessary that for one GUI widget not a single component can be created, but multiple ones are necessary. An example would be a text area in Swing, which is comprised of the Swing text area itself plus a scroll pane object. In this example the outer component would be the scroll pane, the component (returned by
would be the text area. The mechanism with the outer component allows a GUI library specific implementation to construct composite components for certain complex widgets, but from the client's view they behave like a single one.getComponent()
- Returns:
- the outer component
-
getData
T getData()
Returns the data of the wrapped component. This is the data the user has entered, e.g. text.- Returns:
- the component's data
-
setData
void setData(T data)
Sets the data of the wrapped component. This method can be used to initialize GUI widgets, e.g. to set default text at start up.- Parameters:
data
- the data to set
-
getType
Class<?> getType()
Returns the data type used by this component. TheClass
object returned here determines, which type is allowed for thegetData()
andsetData()
methods. It depends on the concrete GUI component. For text fields it will be a string, for checkboxes probably a boolean etc.- Returns:
- the data type used by this component
-
isEnabled
boolean isEnabled()
Returns a flag whether this component is enabled.- Returns:
- the enabled flag
-
setEnabled
void setEnabled(boolean f)
Allows to set the enabled flag. A disabled component cannot be focused and does not accept user input.- Parameters:
f
- the value of the enabled flag
-
-