Package ca.corbett.forms.fields
Class MarginsField
java.lang.Object
ca.corbett.forms.fields.FormField
ca.corbett.forms.fields.MarginsField
A FormField implementation for viewing or editing a Margins instance.
Margins instances have five properties: left, top, right, bottom, and internalSpacing.
This FormField provides a NumberSpinner for each one, and the resulting value
of this field is a Margins instance containing the current values of all five properties.
- Since:
- swing-extras 2.8
- Author:
- scorbo2
-
Field Summary
Fields inherited from class ca.corbett.forms.fields.FormField
DEFAULT_FONT, defaultFont, extraAttributes, fieldComponent, fieldLabel, fieldValidators, helpLabel, ICON_SIZE, identifier, isEnabled, isVisible, margins, validationLabel, valueChangedListeners -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the optional header label text, or null if the header label is not currently shown.Don't confuse this with the getMargins() method from the parent class!booleanWe override this to return true, as we will consume multiple rows in the FormPanel.setEnabled(boolean isEnabled) Overridden here so we can enable or disable all of our spinners and labels as needed when the FormField itself is enabled or disabled.setHeaderLabel(String label) Sets an optional header label to display above the five spinners.setMarginsObject(Margins margins) Sets our field values according to the given Margins instance.Methods inherited from class ca.corbett.forms.fields.FormField
addAllExtraAttributes, addFieldValidator, addValueChangedListener, clearExtraAttribute, clearExtraAttributes, clearValidationResults, equals, fireValueChangedEvent, getDefaultFont, getExtraAttribute, getFieldComponent, getFieldLabel, getHelpLabel, getHelpText, getIdentifier, getMargins, getValidationLabel, hasFieldLabel, hashCode, hasHelpLabel, hasValidationLabel, isEnabled, isValid, isVisible, preRender, removeAllFieldValidators, removeFieldValidator, removeValueChangedListener, setAllExtraAttributes, setDefaultFont, setExtraAttribute, setFieldLabelFont, setHelpText, setIdentifier, setMargins, setVisible, shouldExpand, validate
-
Constructor Details
-
MarginsField
-
MarginsField
-
-
Method Details
-
getMarginsObject
Don't confuse this with the getMargins() method from the parent class! "getMargins()" will return the actual margins for this FormField, which is not what you're looking for. This method will return a Margins instance created from the current values of the five spinners - the value of this field.- Returns:
- A Margins instance containing the current values of all five spinners.
-
setMarginsObject
Sets our field values according to the given Margins instance. If the given instance is null, a new Margins instance with default values will be used instead.- Parameters:
margins- The Margins instance to copy values from, or null to use a new Margins instance with default values.- Returns:
- This MarginsField instance, for chaining.
-
isMultiLine
public boolean isMultiLine()We override this to return true, as we will consume multiple rows in the FormPanel.- Overrides:
isMultiLinein classFormField
-
setEnabled
Overridden here so we can enable or disable all of our spinners and labels as needed when the FormField itself is enabled or disabled.- Overrides:
setEnabledin classFormField- Parameters:
isEnabled- whether to enable or disable the components.
-
setHeaderLabel
Sets an optional header label to display above the five spinners. The three options for labeling this field are:- No label. Pass "" or null for the label parameter to the constructor, or call getFieldLabel().setText(""), and the field label will be hidden. Don't pass in a header label, or set the header label to null, and it also will be hidden.
- A field label (usual FormField behavior). Pass some label text to the constructor, and a field label will be shown to the left of the field, like a normal FormField. Don't pass in a header label, or set the header label to null, and the result will be that only the field label is shown.
- A header label. Pass "" or null for the label parameter to the constructor to hide the field label. Then, pass some label text to this method to set the header label, and the header label will be shown above the five spinners.
A fourth option would be to set both the field label and the header label together, but that seems redundant. It is an option, though, if you really like labeling stuff.
- Parameters:
label- The text to show in the header label, or null to hide the header label.- Returns:
- This MarginsField instance, for chaining.
-
getHeaderLabel
Returns the optional header label text, or null if the header label is not currently shown.- Returns:
- The text of the header label, or null if the header label is not currently shown.
-