public class TextIcon extends Object implements Icon, PropertyChangeListener
| Modifier and Type | Class and Description |
|---|---|
static class |
TextIcon.Layout |
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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
|
public TextIcon(JComponent component, String text)
component - the component to which the icon will be addedtext - the text to be rendered on the Iconpublic 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 VERTICALpublic TextIcon.Layout getLayout()
public String getText()
public void setText(String text)
text - the text to be rendered on the Iconpublic Font getFont()
public void setFont(Font font)
font - the Font to be used for rendering the textpublic Color getForeground()
public void setForeground(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 Iconpublic int getIconHeight()
getIconHeight in interface Iconpublic void paintIcon(Component c, Graphics g, int x, int y)
public void propertyChange(PropertyChangeEvent e)
propertyChange in interface PropertyChangeListenerCopyright © 2023. All rights reserved.