public class IconUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Icon |
colorIcon(Icon icon,
Color color)
Modifies an existing icon by changing its colour.
|
static BufferedImage |
createImage(Icon icon)
Returns an image got by drawing an Icon.
|
static Icon |
createTextIcon(String line,
Graphics g)
Returns an icon that paints a line of text.
|
static Icon |
emptyIcon(int width,
int height)
Returns an icon with a given size and no content.
|
static ImageIcon |
toImageIcon(Icon icon)
Returns an ImageIcon based on a given Icon object.
|
public static Icon emptyIcon(int width, int height)
width
- icon widthheight
- icon heightpublic static Icon colorIcon(Icon icon, Color color)
icon
- input iconcolor
- colour to use as default for paintingpublic static ImageIcon toImageIcon(Icon icon)
icon
is already an ImageIcon, it is returned. Otherwise,
it is painted to an Image and an ImageIcon is constructed from that.
The reason this is useful is that some Swing components will only
grey out disabled icons if they are ImageIcon subclasses (which is
naughty).icon
- input iconpublic static Icon createTextIcon(String line, Graphics g)
line
- text stringg
- graphics contextpublic static BufferedImage createImage(Icon icon)
icon
- iconCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.