public class CompoundIcon
extends java.lang.Object
implements javax.swing.Icon
The CompoundIcon will paint two, or more, Icons as a single Icon. The Icons are painted in the order in which they are added.
The Icons are layed out on the specified axis:
| Modifier and Type | Class and Description |
|---|---|
static class |
CompoundIcon.Axis |
| Constructor and Description |
|---|
CompoundIcon(CompoundIcon.Axis axis,
javax.swing.Icon... icons)
Convenience constructor for creating a CompoundIcon where the gap is 0 and the X/Y alignments
will default to CENTER.
|
CompoundIcon(CompoundIcon.Axis axis,
int gap,
float alignmentX,
float alignmentY,
javax.swing.Icon... icons)
Create a CompoundIcon specifying all the properties.
|
CompoundIcon(CompoundIcon.Axis axis,
int gap,
javax.swing.Icon... icons)
Convenience constructor for creating a CompoundIcon where the X/Y alignments will default to
CENTER.
|
CompoundIcon(javax.swing.Icon... icons)
Convenience contructor for creating a CompoundIcon where the icons are layed out on the X-AXIS,
the gap is 0 and the X/Y alignments will default to CENTER.
|
| Modifier and Type | Method and Description |
|---|---|
float |
getAlignmentX()
Get the alignment of the icon on the x-axis
|
float |
getAlignmentY()
Get the alignment of the icon on the y-axis
|
CompoundIcon.Axis |
getAxis()
Get the Axis along which each icon is painted.
|
int |
getGap()
Get the gap between each icon
|
javax.swing.Icon |
getIcon(int index)
Get the Icon at the specified index.
|
int |
getIconCount()
Get the number of Icons contained in this CompoundIcon.
|
int |
getIconHeight()
Gets the height of this icon.
|
int |
getIconWidth()
Gets the width of this icon.
|
void |
paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
Paint the icons of this compound icon at the specified location
|
public CompoundIcon(javax.swing.Icon... icons)
icons - the Icons to be painted as part of the CompoundIconpublic CompoundIcon(CompoundIcon.Axis axis, javax.swing.Icon... icons)
axis - the axis used to lay out the icons for painting. Must be one of the Axis enums:
X_AXIS, Y_AXIS, Z_Axis.icons - the Icons to be painted as part of the CompoundIconpublic CompoundIcon(CompoundIcon.Axis axis, int gap, javax.swing.Icon... icons)
axis - the axis used to lay out the icons for painting Must be one of the Axis enums:
X_AXIS, Y_AXIS, Z_Axis.gap - the gap between the iconsicons - the Icons to be painted as part of the CompoundIconpublic CompoundIcon(CompoundIcon.Axis axis, int gap, float alignmentX, float alignmentY, javax.swing.Icon... icons)
axis - the axis used to lay out the icons for painting Must be one of the Axis
enums: X_AXIS, Y_AXIS, Z_Axis.gap - the gap between the iconsalignmentX - the X alignment of the icons. Common values are LEFT, CENTER, RIGHT. Can be
any value between 0.0 and 1.0alignmentY - the Y alignment of the icons. Common values are TOP, CENTER, BOTTOM. Can be
any value between 0.0 and 1.0icons - the Icons to be painted as part of the CompoundIconpublic CompoundIcon.Axis getAxis()
public int getGap()
public float getAlignmentX()
public float getAlignmentY()
public int getIconCount()
public javax.swing.Icon getIcon(int index)
index - The index of the Icon to be returnedjava.lang.IndexOutOfBoundsException - if the index is out of rangepublic void paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
paintIcon in interface javax.swing.Iconc - The component on which the icon is paintedg - The graphics contextx - The X coordinate of the icon's top-left cornery - The Y coordinate of the icon's top-left cornerpublic int getIconWidth()
getIconWidth in interface javax.swing.Iconpublic int getIconHeight()
getIconHeight in interface javax.swing.Icon