smile.swing
Class AlphaIcon
- java.lang.Object
-
- smile.swing.AlphaIcon
-
- All Implemented Interfaces:
- javax.swing.Icon
public class AlphaIcon extends java.lang.Object implements javax.swing.IconAn Icon wrapper that paints the contained icon with a specified transparency.Note: This class is not suitable for wrapping an
ImageIconthat holds an animated image.
-
-
Constructor Summary
Constructors Constructor and Description AlphaIcon(javax.swing.Icon icon, float alpha)Creates anAlphaIconwith the specified icon and opacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description floatgetAlpha()Gets thisAlphaIcon's opacityjavax.swing.IcongetIcon()Gets the icon wrapped by thisAlphaIconintgetIconHeight()Gets the height of the bounding rectangle of thisAlphaIcon.intgetIconWidth()Gets the width of the bounding rectangle of thisAlphaIcon.voidpaintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)Paints the wrapped icon with thisAlphaIcon's transparency.
-
-
-
Constructor Detail
-
AlphaIcon
public AlphaIcon(javax.swing.Icon icon, float alpha)Creates anAlphaIconwith the specified icon and opacity. The opacityalphashould be in the range 0.0F (fully transparent) to 1.0F (fully opaque).- Parameters:
icon- the Icon to wrapalpha- the opacity
-
-
Method Detail
-
getAlpha
public float getAlpha()
Gets thisAlphaIcon's opacity- Returns:
- the opacity, in the range 0.0 to 1.0
-
getIcon
public javax.swing.Icon getIcon()
Gets the icon wrapped by thisAlphaIcon- Returns:
- the wrapped icon
-
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)Paints the wrapped icon with thisAlphaIcon's transparency.- Specified by:
paintIconin interfacejavax.swing.Icon- Parameters:
c- The component to 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 corner
-
getIconWidth
public int getIconWidth()
Gets the width of the bounding rectangle of thisAlphaIcon. Returns the width of the wrapped icon.- Specified by:
getIconWidthin interfacejavax.swing.Icon- Returns:
- the width in pixels
-
getIconHeight
public int getIconHeight()
Gets the height of the bounding rectangle of thisAlphaIcon. * Returns the height of the wrapped icon.- Specified by:
getIconHeightin interfacejavax.swing.Icon- Returns:
- the height in pixels
-
-
DataMelt 3.0 © DataMelt by jWork.ORG