Package com.github.tadukoo.view.form
Interface SimpleForm
- All Superinterfaces:
Form
,com.github.tadukoo.util.pojo.MappedPojo
- All Known Subinterfaces:
SimpleMainForm
- All Known Implementing Classes:
AbstractSimpleForm
,AbstractSimpleMainForm
,DateForm
Simple Form represents a form used in a program that the user can fill out and interact with.
It uses
FormField
s for the fields and buttons and such to be displayed on a single tab.- Since:
- Alpha v.0.2
- Version:
- Alpha v.0.3.3
- Author:
- Logan Ferree (Tadukoo)
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
addComponent
(String key, JComponent component) Adds the givenJComponent
to the Components mapdefault void
Adds the givenFormField
to this Formdefault void
This method should be called by the constructor (after callingsetDefaultFields()
), and will create the components to be used on this Formdefault JComponent
getComponentByKey
(String key) Grabs the appropriateJComponent
present on this form for the given key for the fielddefault FormField<?>
getFieldByKey
(String key) default boolean
default void
This method can be called by subclasses to update the values present in the form from the Component valuesvoid
This method should be called by the constructor to set default fields (this is where you should create newFormField
s by callingaddField(FormField)
)Methods inherited from interface com.github.tadukoo.util.pojo.MappedPojo
clear, getItem, getKeys, getListItem, getListItemNoThrow, getListItemNoThrow, getMap, getPojoItem, getPojoItemNoThrow, getPojoItemNoThrow, hasItem, hasKey, isEmpty, removeItem, setItem
-
Method Details
-
getFieldMap
- Returns:
- The Map of
FormField
s by their keys
-
getComponentMap
Map<String,JComponent> getComponentMap()- Returns:
- The Map of
JComponent
s by their keys
-
asComponent
JPanel asComponent()- Specified by:
asComponent
in interfaceForm
- Returns:
- This Form as a
Component
-
saveValues
default void saveValues()This method can be called by subclasses to update the values present in the form from the Component values- Specified by:
saveValues
in interfaceForm
-
labelsOnTop
default boolean labelsOnTop()- Returns:
- Whether to have labels for components above them (true) or to the left (false) - defaults to true
-
addField
Adds the givenFormField
to this Form- Parameters:
field
- TheFormField
to add to this Form
-
setDefaultFields
This method should be called by the constructor to set default fields (this is where you should create newFormField
s by callingaddField(FormField)
)- Throws:
Throwable
- If anything goes wrong in creating the fields
-
getFieldKeys
- Returns:
- The keys in the Map of
FormField
s
-
getFieldByKey
-
addComponent
Adds the givenJComponent
to the Components map- Parameters:
key
- The key to use for theJComponent
component
- TheJComponent
to be stored
-
createComponents
This method should be called by the constructor (after callingsetDefaultFields()
), and will create the components to be used on this Form- Throws:
Throwable
- If anything goes wrong in creating the components
-
getComponentKeys
- Returns:
- The keys in the Map of
JComponent
s
-
getComponentByKey
Grabs the appropriateJComponent
present on this form for the given key for the field- Parameters:
key
- The key used by the field to find theJComponent
- Returns:
- The appropriate
JComponent
for the given key for its field
-