public class TitledBorder extends AbstractBorder
If the border, font, or color property values are not specified in the constructor or by invoking the appropriate set methods, the property values will be defined by the current look and feel, using the following property names in the Defaults Table:
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
| Modifier and Type | Field and Description |
|---|---|
static int |
ABOVE_BOTTOM
Position the title above the border's bottom line.
|
static int |
ABOVE_TOP
Position the title above the border's top line.
|
static int |
BELOW_BOTTOM
Position the title below the border's bottom line.
|
static int |
BELOW_TOP
Position the title below the border's top line.
|
protected Border |
border
|
static int |
BOTTOM
Position the title in the middle of the border's bottom line.
|
static int |
CENTER
Position title text in the center of the border line.
|
static int |
DEFAULT_JUSTIFICATION
Use the default justification for the title text.
|
static int |
DEFAULT_POSITION
Use the default vertical orientation for the title text.
|
protected static int |
EDGE_SPACING
|
static int |
LEADING
Position title text at the left side of the border line for left to right orientation, at the right side of the border line for right to left orientation.
|
static int |
LEFT
Position title text at the left side of the border line.
|
static int |
RIGHT
Position title text at the right side of the border line.
|
protected static int |
TEXT_INSET_H
|
protected static int |
TEXT_SPACING
|
protected String |
title
|
protected Color |
titleColor
|
protected Font |
titleFont
|
protected int |
titleJustification
|
protected int |
titlePosition
|
static int |
TOP
Position the title in the middle of the border's top line.
|
static int |
TRAILING
Position title text at the right side of the border line for left to right orientation, at the left side of the border line for right to left orientation.
|
| Constructor and Description |
|---|
TitledBorder(Border
Creates a TitledBorder instance with the specified border and an empty title.
|
TitledBorder(Border
Creates a TitledBorder instance with the specified border and title.
|
TitledBorder(Border
Creates a TitledBorder instance with the specified border, title, title-justification, and title-position.
|
TitledBorder(Border
Creates a TitledBorder instance with the specified border, title, title-justification, title-position, and title-font.
|
TitledBorder(Border
Creates a TitledBorder instance with the specified border, title, title-justification, title-position, title-font, and title-color.
|
TitledBorder(String
Creates a TitledBorder instance.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getBaseline(Component
Returns the baseline.
|
Component |
getBaselineResizeBehavior(Component
Returns an enum indicating how the baseline of the border changes as the size changes.
|
Border |
getBorder()
Returns the border of the titled border.
|
Insets |
getBorderInsets(Component
Reinitialize the insets parameter with this Border's current Insets.
|
protected Font |
getFont(Component
|
Dimension |
getMinimumSize(Component
Returns the minimum dimensions this border requires in order to fully display the border and title.
|
String |
getTitle()
Returns the title of the titled border.
|
Color |
getTitleColor()
Returns the title-color of the titled border.
|
Font |
getTitleFont()
Returns the title-font of the titled border.
|
int |
getTitleJustification()
Returns the title-justification of the titled border.
|
int |
getTitlePosition()
Returns the title-position of the titled border.
|
boolean |
isBorderOpaque()
Returns whether or not the border is opaque.
|
void |
paintBorder(Component
Paints the border for the specified component with the specified position and size.
|
void |
setBorder(Border
Sets the border of the titled border.
|
void |
setTitle(String
Sets the title of the titled border.
|
void |
setTitleColor(Color
Sets the title-color of the titled border.
|
void |
setTitleFont(Font
Sets the title-font of the titled border.
|
void |
setTitleJustification(int titleJustification)
Sets the title-justification of the titled border.
|
void |
setTitlePosition(int titlePosition)
Sets the title-position of the titled border.
|
getBorderInsets, getInteriorRectangle, getInteriorRectangleprotected Stringtitle
protected Borderborder
protected int titlePosition
protected int titleJustification
protected FonttitleFont
protected ColortitleColor
public static final int DEFAULT_POSITION
public static final int ABOVE_TOP
public static final int TOP
public static final int BELOW_TOP
public static final int ABOVE_BOTTOM
public static final int BOTTOM
public static final int BELOW_BOTTOM
public static final int DEFAULT_JUSTIFICATION
public static final int LEFT
public static final int CENTER
public static final int RIGHT
public static final int LEADING
public static final int TRAILING
protected static final int EDGE_SPACING
protected static final int TEXT_SPACING
protected static final int TEXT_INSET_H
public TitledBorder(Stringtitle)
title - the title the border should display
public TitledBorder(Borderborder)
border - the border
public TitledBorder(Borderborder, String title)
border - the border
title - the title the border should display
public TitledBorder(Borderborder, String title, int titleJustification, int titlePosition)
border - the border
title - the title the border should display
titleJustification - the justification for the title
titlePosition - the position for the title
public TitledBorder(Borderborder, String title, int titleJustification, int titlePosition, Font titleFont)
border - the border
title - the title the border should display
titleJustification - the justification for the title
titlePosition - the position for the title
titleFont - the font for rendering the title
@ConstructorProperties(value={"border","title","titleJustification","titlePosition","titleFont","titleColor"}) public TitledBorder(Borderborder, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)
border - the border
title - the title the border should display
titleJustification - the justification for the title
titlePosition - the position for the title
titleFont - the font of the title
titleColor - the color of the title
public void paintBorder(Componentc, Graphics g, int x, int y, int width, int height)
paintBorder in interface
Border
paintBorder in class
AbstractBorder
c - the component for which this border is being painted
g - the paint graphics
x - the x position of the painted border
y - the y position of the painted border
width - the width of the painted border
height - the height of the painted border
public InsetsgetBorderInsets(Component c, Insets insets)
getBorderInsets in class
AbstractBorder
c - the component for which this border insets value applies
insets - the object to be reinitialized
insets object
public boolean isBorderOpaque()
isBorderOpaque in interface
Border
isBorderOpaque in class
AbstractBorder
public StringgetTitle()
public BordergetBorder()
public int getTitlePosition()
public int getTitleJustification()
public FontgetTitleFont()
public ColorgetTitleColor()
public void setTitle(Stringtitle)
title - the title for the border
public void setBorder(Borderborder)
border - the border
public void setTitlePosition(int titlePosition)
titlePosition - the position for the border
public void setTitleJustification(int titleJustification)
titleJustification - the justification for the border
public void setTitleFont(FonttitleFont)
titleFont - the font for the border title
public void setTitleColor(ColortitleColor)
titleColor - the color for the border title
public DimensiongetMinimumSize(Component c)
c - the component where this border will be drawn
Dimension object
public int getBaseline(Componentc, int width, int height)
getBaseline in class
AbstractBorder
c -
Component baseline is being requested for
width - the width to get the baseline for
height - the height to get the baseline for
NullPointerException -
IllegalArgumentException - if width or height is < 0
JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(Component c)
getBaselineResizeBehavior in class
AbstractBorder
c -
Component to return baseline resize behavior for
NullPointerException -
JComponent.getBaseline(int, int)