Package com.jidesoft.swing
Class IconBorder
java.lang.Object
javax.swing.border.AbstractBorder
javax.swing.border.EmptyBorder
javax.swing.border.MatteBorder
com.jidesoft.swing.IconBorder
- All Implemented Interfaces:
Serializable
,Border
IconBorder creates a border that places an Icon in the border on one or several sides. For example, if you want to an
icon on the left side, you make the left inset to be the width of the icon, and 0 for the top, right and bottom
insets. Then you can call
setHorizontalIconAlignment(int)
and set it to TOP or CENTER or BOTTOM.
This border is useful when attempting to add Icons to pre-existing components without requiring specialty painting.
For example, use in the CellStyle to decorate the cell renderer with an icon.- Since:
- 3.3.3
- See Also:
-
Field Summary
Fields inherited from class javax.swing.border.MatteBorder
color, tileIcon
Fields inherited from class javax.swing.border.EmptyBorder
bottom, left, right, top
-
Constructor Summary
ConstructorsConstructorDescriptionIconBorder
(int top, int left, int bottom, int right, Icon icon) Creates an IconBorder.IconBorder
(Insets borderInsets, Icon icon) Creates an IconBorder.IconBorder
(Icon icon) Creates an IconBorder with an icon.IconBorder
(Icon icon, int verticalIconAlignment) Creates an IconBorder with an icon. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the icon alignment on the x axis.int
Gets the icon alignment on the y axis.void
paintBorder
(Component c, Graphics g, int x, int y, int width, int height) void
setHorizontalIconAlignment
(int horizontalIconAlignment) Sets the alignment of the icon relative to the component contents.void
setVerticalIconAlignment
(int verticalIconAlignment) Sets the alignment of the icon relative to the component contents.Methods inherited from class javax.swing.border.MatteBorder
getBorderInsets, getBorderInsets, getMatteColor, getTileIcon, isBorderOpaque
Methods inherited from class javax.swing.border.AbstractBorder
getBaseline, getBaselineResizeBehavior, getBorderInsets, getInteriorRectangle, getInteriorRectangle
-
Constructor Details
-
IconBorder
Creates an IconBorder with an icon. The right inset is the same as the icon width and 0 for all other insets. The vertical icon alignment is set to TOP by default.- Parameters:
icon
- the icon.
-
IconBorder
Creates an IconBorder with an icon. The right inset is the same as the icon width and 0 for all other insets.- Parameters:
icon
- the icon.verticalIconAlignment
- the vertical icon alignment.
-
IconBorder
Creates an IconBorder. The icon alignment is set to either TOP or TRAILING depending on value of the insets.- Parameters:
borderInsets
- the insets of the border.icon
- the icon
-
IconBorder
Creates an IconBorder. The icon alignment is set to either TOP or TRAILING depending on value of the insets.- Parameters:
top
- the top inset of the borderleft
- the left inset of the borderbottom
- the bottom inset of the borderright
- the right inset of the bordericon
- the icon.
-
-
Method Details
-
getHorizontalIconAlignment
public int getHorizontalIconAlignment()Gets the icon alignment on the x axis. It is used to paint the icon when the top or bottom insets are not 0.- Returns:
- the horizontal icon alignment.
-
setHorizontalIconAlignment
public void setHorizontalIconAlignment(int horizontalIconAlignment) Sets the alignment of the icon relative to the component contents. This must be one of the following SwingConstants:- LEADING: respects the component orientation
- TRAILING: respects the component orientation
- LEFT
- RIGHT
- CENTER
- Parameters:
horizontalIconAlignment
- one of the five SwingConstants listed above.
-
getVerticalIconAlignment
public int getVerticalIconAlignment()Gets the icon alignment on the y axis. It is used to paint the icon when the left or right insets are not 0.- Returns:
- the vertical icon alignment.
-
setVerticalIconAlignment
public void setVerticalIconAlignment(int verticalIconAlignment) Sets the alignment of the icon relative to the component contents. This must be one of the following SwingConstants:- TOP
- BOTTOM
- CENTER
- Parameters:
verticalIconAlignment
- one of the three SwingConstants listed above.
-
paintBorder
- Specified by:
paintBorder
in interfaceBorder
- Overrides:
paintBorder
in classMatteBorder
-