|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.wordpress.tipsforjava.swing.DualIcon
public class DualIcon extends Object
A composite Icon class used to compose two Icon objects into a single Icon by painting the icons in turn at the precomputed offsets. For example, this class may be used to add a custom icon to a component like JCheckBox or JRadioButton, in addition to the default icon provided by the Look and Feel.
| Field Summary | |
|---|---|
private int |
height
|
Icon |
icon1
|
private int |
icon1HOffset
|
private int |
icon1VOffset
|
Icon |
icon2
|
private int |
icon2HOffset
|
private int |
icon2VOffset
|
private int |
iconIconGap
|
private int |
width
|
| Constructor Summary | |
DualIcon(Icon icon1, Icon icon2)
Creates a |
|
DualIcon(Icon icon1, Icon icon2, int horizontalPosition, int verticalPosition, int iconIconGap)
Creates a |
|
| Method Summary | |
|---|---|
private int
|
checkHorizontalKey(int key, String exception)
|
private int
|
checkVerticalKey(int key, String exception)
|
int
|
getIconHeight()
Gets the height of the the bounding rectangle of this
|
int
|
getIconWidth()
Gets the width of the bounding rectangle of this
|
void
|
paintIcon(Component c, Graphics g, int x, int y)
Paints the icons of this compound icon at the specified location with the precomputed offsets. |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private int height
Icon icon1
private int icon1HOffset
private int icon1VOffset
Icon icon2
private int icon2HOffset
private int icon2VOffset
private int iconIconGap
private int width
| Constructor Detail |
|---|
public DualIcon(Icon icon1, Icon icon2)
DualIcon with the specified icons, the default
horizontal and vertical positioning and default gap.
icon2 is positioned to the right of icon1
with a 4 pixel gap, and the vertical centers of the icons are aligned.
icon1 - the first iconicon2 - the second icon
public DualIcon(Icon icon1, Icon icon2, int horizontalPosition, int verticalPosition, int iconIconGap)
DualIcon with the specified icons, the specified
horizontal and vertical positioning and the specified gap.
icon1 - the first iconicon2 - the second iconhorizontalPosition - of the second icon relative to the first.
verticalPosition - of the second icon relative to the first.
iconIconGap - the gap between the icons in pizels, ignored if the
horizontalPosition and verticalPosition are both
SwingConstants.CENTER.
| Method Detail |
|---|
private int checkHorizontalKey(int key, String exception)
private int checkVerticalKey(int key, String exception)
@Override public int getIconHeight()
DualIcon.
@Override public int getIconWidth()
DualIcon.
@Override public void paintIcon(Component c, Graphics g, int x, int y)
c - The component to which the icon is painted, which may be used
to get properties useful for painting, e.g. the foreground or background
color or selection status.g - the graphics contextx - the X coordinate of the compound icon's top-left cornery - the Y coordinate of the compound icon's top-left corner
Groovy Documentation