Package uk.ac.starlink.util
Class IconUtils
- java.lang.Object
-
- uk.ac.starlink.util.IconUtils
-
public class IconUtils extends java.lang.Object
Utility functions related to Icons.- Since:
- 6 Mar 2013
- Author:
- Mark Taylor
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.swing.Icon
colorIcon(javax.swing.Icon icon, java.awt.Color color)
Modifies an existing icon by changing its colour.static javax.swing.Icon
createTextIcon(java.lang.String line, java.awt.Graphics g)
Returns an icon that paints a line of text.static javax.swing.Icon
emptyIcon(int width, int height)
Returns an icon with a given size and no content.static javax.swing.ImageIcon
toImageIcon(javax.swing.Icon icon)
Returns an ImageIcon based on a given Icon object.
-
-
-
Method Detail
-
emptyIcon
public static javax.swing.Icon emptyIcon(int width, int height)
Returns an icon with a given size and no content.- Parameters:
width
- icon widthheight
- icon height
-
colorIcon
public static javax.swing.Icon colorIcon(javax.swing.Icon icon, java.awt.Color color)
Modifies an existing icon by changing its colour. The colour attribute of the graphics context is changed before the icon is painted.- Parameters:
icon
- input iconcolor
- colour to use as default for painting- Returns:
- output icon
-
toImageIcon
public static javax.swing.ImageIcon toImageIcon(javax.swing.Icon icon)
Returns an ImageIcon based on a given Icon object. If the suppliedicon
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).- Parameters:
icon
- input icon- Returns:
- image icon
-
createTextIcon
public static javax.swing.Icon createTextIcon(java.lang.String line, java.awt.Graphics g)
Returns an icon that paints a line of text.- Parameters:
line
- text stringg
- graphics context- Returns:
- icon
-
-