@JavaBean public class IconBorder extends Object implements Border, Serializable
IconBorder creates a border that places an Icon in the border
on the horizontal axis. The border does not add any additional insets other
than the inset required to produce the space for the icon. If additional
insets are required, users should create a
compund border.
This border is useful when attempting to add Icons to pre-existing
components without requiring specialty painting.
| Modifier and Type | Field and Description |
|---|---|
static Icon |
EMPTY_ICON
An empty icon.
|
| Constructor and Description |
|---|
IconBorder()
Creates an
IconBorder with an empty icon in a trailing position
with a padding of 4. |
IconBorder(Icon validIcon)
Creates an
IconBorder with the specified icon in a trailing
position with a padding of 4. |
IconBorder(Icon validIcon,
int iconPosition)
Creates an
IconBorder with the specified constraints and a
padding of 4. |
IconBorder(Icon validIcon,
int iconPosition,
int padding)
Creates an
IconBorder with the specified constraints. |
| Modifier and Type | Method and Description |
|---|---|
Insets |
getBorderInsets(Component c) |
int |
getIconPosition()
Returns the position to place the icon (relative to the component contents).
|
int |
getPadding()
Gets the padding surrounding the icon.
|
boolean |
isBorderOpaque()
This border is not opaque.
|
void |
paintBorder(Component c,
Graphics g,
int x,
int y,
int width,
int height) |
void |
setIcon(Icon validIcon)
Sets the icon for this border.
|
void |
setIconPosition(int iconPosition)
Sets the position to place the icon (relative to the component contents).
|
void |
setPadding(int padding)
Sets the padding around the icon.
|
public static final Icon EMPTY_ICON
public IconBorder()
IconBorder with an empty icon in a trailing position
with a padding of 4.EMPTY_ICONpublic IconBorder(Icon validIcon)
IconBorder with the specified icon in a trailing
position with a padding of 4.validIcon - the icon to set. This may be null to represent an
empty icon.EMPTY_ICONpublic IconBorder(Icon validIcon, int iconPosition)
IconBorder with the specified constraints and a
padding of 4.validIcon - the icon to set. This may be null to represent an
empty icon.iconPosition - the position to place the icon relative to the component
contents. This must be one of the following
SwingConstants:
LEADINGTRAILINGEASTWESTIllegalArgumentException - if iconPosition is not a valid position.EMPTY_ICONpublic IconBorder(Icon validIcon, int iconPosition, int padding)
IconBorder with the specified constraints. If
validIcon is null, EMPTY_ICON is used instead.
If padding is negative, then the border does not use padding.validIcon - the icon to set. This may be null to represent an
empty icon.iconPosition - the position to place the icon relative to the component
contents. This must be one of the following
SwingConstants:
LEADINGTRAILINGEASTWESTpadding - the padding to surround the icon with. All non-positive values
set the padding to 0.IllegalArgumentException - if iconPosition is not a valid position.EMPTY_ICONpublic Insets getBorderInsets(Component c)
getBorderInsets in interface Borderpublic void setIcon(Icon validIcon)
validIcon - the icon to set. This may be null to represent an
empty icon.EMPTY_ICONpublic boolean isBorderOpaque()
isBorderOpaque in interface Borderfalsepublic void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
paintBorder in interface Borderpublic int getPadding()
public void setPadding(int padding)
padding - the padding to set. If padding < 0, then
padding will be set to 0.public int getIconPosition()
SwingConstants:
LEADINGTRAILINGEASTWESTpublic void setIconPosition(int iconPosition)
iconPosition - must be one of the following SwingConstants:
LEADINGTRAILINGEASTWESTIllegalArgumentException - if iconPosition is not a valid position.Copyright © 2017. All Rights Reserved.