|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.wordpress.tipsforjava.swing.TextIcon
public class TextIcon extends Object
The TextIcon will paint a String of text as an Icon. The Icon can be used by any Swing component that supports icons. TextIcon supports two different layout styles:
| Nested Class Summary | |
|---|---|
enum |
TextIcon.Layout
|
| Field Summary | |
|---|---|
private JComponent |
component
The TextIcon will paint a String of text as an Icon. |
private Font |
font
|
private Color |
foreground
|
private int |
iconHeight
|
private int |
iconWidth
|
private TextIcon.Layout |
layout
|
private int |
padding
|
private int[] |
stringWidths
|
private String[] |
strings
|
private String |
text
|
| Constructor Summary | |
TextIcon(JComponent component, String text)
Convenience constructor to create a TextIcon with a HORIZONTAL layout. |
|
TextIcon(JComponent component, String text, TextIcon.Layout layout)
Create a TextIcon specifying all the properties. |
|
| Method Summary | |
|---|---|
private void
|
calculateIconDimensions()
Calculate the size of the Icon using the FontMetrics of the Font. |
Font
|
getFont()
Get the Font used to render the text. |
Color
|
getForeground()
Get the foreground Color used to render the text. |
int
|
getIconHeight()
Gets the height of this icon. |
int
|
getIconWidth()
Gets the width of this icon. |
TextIcon.Layout
|
getLayout()
Get the Layout enum |
int
|
getPadding()
Get the padding used when rendering the text |
String
|
getText()
Get the text String that will be rendered on the Icon |
void
|
paintIcon(Component c, Graphics g, int x, int y)
Paint the icons of this compound icon at the specified location |
void
|
propertyChange(PropertyChangeEvent e)
|
void
|
setFont(Font font)
Set the Font to be used for rendering the text |
void
|
setForeground(Color foreground)
Set the foreground Color to be used for rendering the text |
void
|
setPadding(int padding)
By default the size of the Icon is based on the size of the rendered text. |
void
|
setText(String text)
Set the text to be rendered on the Icon |
TextIcon
|
valueOf(String name)
Returns the enum constant of this type with the specified name. |
TextIcon[]
|
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private JComponent component
private Font font
private Color foreground
private int iconHeight
private int iconWidth
private TextIcon.Layout layout
private int padding
private int[] stringWidths
private String[] strings
private String text
| Constructor Detail |
|---|
public TextIcon(JComponent component, String text)
component - the component to which the icon will be addedtext - the text to be rendered on the Icon
public TextIcon(JComponent component, String text, TextIcon.Layout layout)
component - the component to which the icon will be addedtext - the text to be rendered on the Iconlayout - specify the layout of the text. Must be one of
the Layout enums: HORIZONTAL or VERTICAL
| Method Detail |
|---|
private void calculateIconDimensions()
public Font getFont()
public Color getForeground()
de public public int getIconHeight()
de public public int getIconWidth()
public TextIcon.Layout getLayout()
public int getPadding()
public String getText()
de public public void paintIcon(Component c, Graphics g, int x, int y)
c - The component to which the icon is addedg - the graphics contextx - the X coordinate of the icon's top-left cornery - the Y coordinate of the icon's top-left corner
public void propertyChange(PropertyChangeEvent e)
public void setFont(Font font)
font - the Font to be used for rendering the text
public void setForeground(Color foreground)
foreground - the foreground Color to be used for rendering the text
public void setPadding(int padding)
padding - the padding amount in pixels
public void setText(String text)
text - the text to be rendered on the Icon
TextIcon valueOf(String name)
TextIcon[] values()
Groovy Documentation