public class TextIcon
extends java.lang.Object
implements javax.swing.Icon, java.beans.PropertyChangeListener
| Modifier and Type | Class and Description |
|---|---|
static class |
TextIcon.Layout |
| Constructor and Description |
|---|
TextIcon(javax.swing.JComponent component,
java.lang.String text)
Convenience constructor to create a TextIcon with a HORIZONTAL layout.
|
TextIcon(javax.swing.JComponent component,
java.lang.String text,
TextIcon.Layout layout)
Create a TextIcon specifying all the properties.
|
| Modifier and Type | Method and Description |
|---|---|
java.awt.Font |
getFont()
Get the Font used to render the text.
|
java.awt.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
|
java.lang.String |
getText()
Get the text String that will be rendered on the 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
|
void |
propertyChange(java.beans.PropertyChangeEvent e) |
void |
setFont(java.awt.Font font)
Set the Font to be used for rendering the text
|
void |
setForeground(java.awt.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(java.lang.String text)
Set the text to be rendered on the Icon
|
public TextIcon(javax.swing.JComponent component,
java.lang.String text)
component - the component to which the icon will be addedtext - the text to be rendered on the Iconpublic TextIcon(javax.swing.JComponent component,
java.lang.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 VERTICALpublic TextIcon.Layout getLayout()
public java.lang.String getText()
public void setText(java.lang.String text)
text - the text to be rendered on the Iconpublic java.awt.Font getFont()
public void setFont(java.awt.Font font)
font - the Font to be used for rendering the textpublic java.awt.Color getForeground()
public void setForeground(java.awt.Color foreground)
foreground - the foreground Color to be used for rendering the textpublic int getPadding()
public void setPadding(int padding)
padding - the padding amount in pixelspublic int getIconWidth()
getIconWidth in interface javax.swing.Iconpublic int getIconHeight()
getIconHeight in interface javax.swing.Iconpublic void paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
paintIcon in interface javax.swing.Iconc - 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 cornerpublic void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange in interface java.beans.PropertyChangeListener