Class Margins
The left, right, top, and bottom properties apply margins outside the target component. That is, the space between the component and the edge of its container. For example, in the case of a FormField:
- left - the "indent" between the left edge of the FormPanel and the left edge of the FormField.
- right - the space between the right edge of the FormField and the right edge of the FormPanel.
- top - the space between the top edge of the FormField and either the previous FormField on the same FormPanel, or the top edge of the FormPanel if this is the first FormField.
- bottom - the space between the bottom edge of the FormField and either the next FormField on the same FormPanel, or the bottom edge of the FormPanel if this is the last FormField.
The internalSpacing property applies extra space within the component. For example, in the case of a FormField, this is the extra space between the various subcomponents of the FormField. That is, the space between the field label and the field component, between the field component and the help label, and between the help label and the validation label.
Any component that supports this Margins class can apply the properties in a way that makes sense for that component. The examples above are specific to FormField, but this Margins class can be used for other components as well.
- Since:
- swing-extras 2.4
- Author:
- scorbo2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA very simple interface that can be used to listen for changes to a Margins instance. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMargins()Creates a new Margins instance with all properties set to a hard-coded default of 4 pixels.Margins(int all) Creates a new Margins instance with all properties set to the given pixel value.Margins(int left, int top, int right, int bottom, int internalSpacing) Creates a new Margins instance with the given properties (all values in pixels).Creates a new Margins instance by copying values from the given other Margins instance. -
Method Summary
Modifier and TypeMethodDescriptionaddListener(Margins.Listener listener) You can listen for changes to this Margins instance by adding a Listener.Copies all values from the given other Margins instance.booleanintintintgetLeft()intgetRight()intgetTop()inthashCode()removeListener(Margins.Listener listener) You can stop listening to this Margins instance by removing a Listener that was previously added via addListener().setAll(int value) Set all values to the given pixel value.setBottom(int bottom) setInternalSpacing(int internalSpacing) setLeft(int left) setRight(int right) setTop(int top)
-
Field Details
-
DEFAULT_MARGIN
public static final int DEFAULT_MARGIN- See Also:
-
-
Constructor Details
-
Margins
public Margins()Creates a new Margins instance with all properties set to a hard-coded default of 4 pixels. -
Margins
public Margins(int all) Creates a new Margins instance with all properties set to the given pixel value. -
Margins
public Margins(int left, int top, int right, int bottom, int internalSpacing) Creates a new Margins instance with the given properties (all values in pixels). -
Margins
Creates a new Margins instance by copying values from the given other Margins instance. If the given instance is null, this is equivalent to new Margins().
-
-
Method Details
-
copy
Copies all values from the given other Margins instance. If the given instance is null, this call does nothing. -
setAll
Set all values to the given pixel value. -
getLeft
public int getLeft() -
setLeft
-
getTop
public int getTop() -
setTop
-
getRight
public int getRight() -
setRight
-
getBottom
public int getBottom() -
setBottom
-
getInternalSpacing
public int getInternalSpacing() -
setInternalSpacing
-
addListener
You can listen for changes to this Margins instance by adding a Listener. Whenever any property of this Margins instance is changed, all registered listeners will be notified via their marginsChanged() method. -
removeListener
You can stop listening to this Margins instance by removing a Listener that was previously added via addListener(). -
equals
-
hashCode
public int hashCode()
-