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:
java.io.Serializable
,javax.swing.border.Border
public class IconBorder extends javax.swing.border.MatteBorder
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 callsetHorizontalIconAlignment(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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IconBorder(int top, int left, int bottom, int right, javax.swing.Icon icon)
Creates an IconBorder.IconBorder(java.awt.Insets borderInsets, javax.swing.Icon icon)
Creates an IconBorder.IconBorder(javax.swing.Icon icon)
Creates an IconBorder with an icon.IconBorder(javax.swing.Icon icon, int verticalIconAlignment)
Creates an IconBorder with an icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getHorizontalIconAlignment()
Gets the icon alignment on the x axis.int
getVerticalIconAlignment()
Gets the icon alignment on the y axis.void
paintBorder(java.awt.Component c, java.awt.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
-
-
-
-
Constructor Detail
-
IconBorder
public IconBorder(javax.swing.Icon icon)
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
public IconBorder(javax.swing.Icon icon, int verticalIconAlignment)
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
public IconBorder(java.awt.Insets borderInsets, javax.swing.Icon icon)
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
public IconBorder(int top, int left, int bottom, int right, javax.swing.Icon icon)
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 Detail
-
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
public void paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
- Specified by:
paintBorder
in interfacejavax.swing.border.Border
- Overrides:
paintBorder
in classjavax.swing.border.MatteBorder
-
-