Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.border.AbstractBorder
javax.swing.border.TitledBorder
public class TitledBorder
extends AbstractBorder
Field Summary | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
protected static int |
|
static int |
|
static int |
|
static int |
|
protected static int |
|
protected static int |
|
static int |
|
static int |
|
protected Border |
|
protected String |
|
protected Color |
|
protected Font |
|
protected int |
|
protected int |
|
Constructor Summary | |
| |
| |
| |
| |
| |
|
Method Summary | |
Border |
|
Insets |
|
Insets |
|
protected Font | |
Dimension |
|
String |
|
Color |
|
Font |
|
int |
|
int |
|
boolean |
|
void |
|
void | |
void | |
void |
|
void |
|
void |
|
void |
|
Methods inherited from class javax.swing.border.AbstractBorder | |
getBorderInsets , getBorderInsets , getInteriorRectangle , getInteriorRectangle , isBorderOpaque , paintBorder |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int ABOVE_BOTTOM
A value for thetitlePosition
property that vertically positions the title text above the bottom line of the border.
- Field Value:
- 4
- See Also:
getTitlePosition()
,setTitlePosition(int)
public static final int ABOVE_TOP
A value for thetitlePosition
property that vertically positions the title text above the top line of the border.
- Field Value:
- 1
- See Also:
getTitlePosition()
,setTitlePosition(int)
public static final int BELOW_BOTTOM
A value for thetitlePosition
property that vertically positions the title text below the bottom line of the border.
- Field Value:
- 6
- See Also:
getTitlePosition()
,setTitlePosition(int)
public static final int BELOW_TOP
A value for thetitlePosition
property that vertically positions the title text below the top line of the border.
- Field Value:
- 3
- See Also:
getTitlePosition()
,setTitlePosition(int)
public static final int BOTTOM
A value for thetitlePosition
property that vertically positions the title text at the center of the bottom line of the border.
- Field Value:
- 5
- See Also:
getTitlePosition()
,setTitlePosition(int)
public static final int CENTER
A value for thetitleJustification
property that horizontally aligns the title text with the center of the border.
- Field Value:
- 2
public static final int DEFAULT_JUSTIFICATION
A value for thetitleJustification
property that horizontally aligns the title text with either the left or the right edge of the border, depending on the orientation of the component nested into the border. If the component orientation is left-to-right, the title text is aligned with the left edge; otherwise, it is aligned with the right edge. This is the same behavior as withLEADING
.
- Field Value:
- 0
public static final int DEFAULT_POSITION
A value for thetitlePosition
property that vertically positions the title text at the default vertical position, which is in the middle of the top line of the border.
- Field Value:
- 0
- See Also:
getTitlePosition()
,setTitlePosition(int)
protected static final int EDGE_SPACING
The number of pixels between the inside ofborder
and the bordered component.
- Field Value:
- 2
public static final int LEADING
A value for thetitleJustification
property that horizontally aligns the title text with either the left or the right edge of the border, depending on the orientation of the component nested into the border. If the component orientation is left-to-right, the title text is aligned with the left edge; otherwise, it is aligned with the right edge. This is the same behavior as withDEFAULT_JUSTIFICATION
.
- Field Value:
- 4
public static final int LEFT
A value for thetitleJustification
property that horizontally aligns the title text with the left-hand edge of the border.
- Field Value:
- 1
public static final int RIGHT
A value for thetitleJustification
property that horizontally aligns the title text with the right-hand edge of the border.
- Field Value:
- 3
protected static final int TEXT_INSET_H
The number of pixels between the outside of this TitledBorder and the beginning (if left-aligned) or end (if right-aligned) of the title text.
- Field Value:
- 5
protected static final int TEXT_SPACING
The number of pixels between the title text andborder
. This value is only relevant if the title text does not intersectborder
. No intersection occurs iftitlePosition
is one ofABOVE_TOP
,BELOW_TOP
,ABOVE_BOTTOM
, orBELOW_BOTTOM
.
- Field Value:
- 2
public static final int TOP
A value for thetitlePosition
property that vertically positions the title text at the middle of the top line of the border.
- Field Value:
- 2
- See Also:
getTitlePosition()
,setTitlePosition(int)
public static final int TRAILING
A value for thetitleJustification
property that horizontally aligns the title text with either the right or the left edge of the border, depending on the orientation of the component nested into the border. If the component orientation is left-to-right, the title text is aligned with the right edge; otherwise, it is aligned with the left edge.
- Field Value:
- 5
protected Border border
The border underneath the title. If this value isnull
, the border will be retrieved from theUIManager
’s defaults table using the keyTitledBorder.border
.
protected Color titleColor
The color for displaying the title text. If this value isnull
, the color will be retrieved from theUIManager
’s defaults table using the keyTitledBorder.titleColor
.
protected Font titleFont
The font for displaying the title text. If this value isnull
, the font will be retrieved from theUIManager
’s defaults table using the keyTitledBorder.font
.
protected int titlePosition
The vertical position of the title text relative to the border, which is one ofABOVE_TOP
,TOP
,BELOW_TOP
,ABOVE_BOTTOM
,BOTTOM
,BELOW_BOTTOM
, orDEFAULT_POSITION
.
public TitledBorder(String title)
Constructs a TitledBorder given the text of its title.
- Parameters:
title
- the title text, ornull
to use no title text.
public TitledBorder(Border border)
Constructs an initially untitled TitledBorder given another border.
- Parameters:
border
- the border underneath the title, ornull
to use a default from the current look and feel.
public TitledBorder(Border border, String title)
Constructs a TitledBorder given its border and title text.
- Parameters:
border
- the border underneath the title, ornull
to use a default from the current look and feel.title
- the title text, ornull
to use no title text.
public TitledBorder(Border border, String title, int titleJustification, int titlePosition)
Constructs a TitledBorder given its border, title text, horizontal alignment, and vertical position.
- Parameters:
border
- the border underneath the title, ornull
to use a default from the current look and feel.title
- the title text, ornull
to use no title text.titleJustification
- the horizontal alignment of the title text in relation to the border. The value must be one ofLEFT
,CENTER
,RIGHT
,LEADING
,TRAILING
, orDEFAULT_JUSTIFICATION
.titlePosition
- the vertical position of the title text in relation to the border. The value must be one ofABOVE_TOP
,TOP
,BELOW_TOP
,ABOVE_BOTTOM
,BOTTOM
,BELOW_BOTTOM
, orDEFAULT_POSITION
.
- Throws:
IllegalArgumentException
- iftitleJustification
ortitlePosition
have an unsupported value.
public TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont)
Constructs a TitledBorder given its border, title text, horizontal alignment, vertical position, and font.
- Parameters:
border
- the border underneath the title, ornull
to use a default from the current look and feel.title
- the title text, ornull
to use no title text.titleJustification
- the horizontal alignment of the title text in relation to the border. The value must be one ofLEFT
,CENTER
,RIGHT
,LEADING
,TRAILING
, orDEFAULT_JUSTIFICATION
.titlePosition
- the vertical position of the title text in relation to the border. The value must be one ofABOVE_TOP
,TOP
,BELOW_TOP
,ABOVE_BOTTOM
,BOTTOM
,BELOW_BOTTOM
, orDEFAULT_POSITION
.titleFont
- the font for the title text, ornull
to use a default from the current look and feel.
- Throws:
IllegalArgumentException
- iftitleJustification
ortitlePosition
have an unsupported value.
public TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)
Constructs a TitledBorder given its border, title text, horizontal alignment, vertical position, font, and color.
- Parameters:
border
- the border underneath the title, ornull
to use a default from the current look and feel.title
- the title text, ornull
to use no title text.titleJustification
- the horizontal alignment of the title text in relation to the border. The value must be one ofLEFT
,CENTER
,RIGHT
,LEADING
,TRAILING
, orDEFAULT_JUSTIFICATION
.titlePosition
- the vertical position of the title text in relation to the border. The value must be one ofABOVE_TOP
,TOP
,BELOW_TOP
,ABOVE_BOTTOM
,BOTTOM
,BELOW_BOTTOM
, orDEFAULT_POSITION
.titleFont
- the font for the title text, ornull
to use a default from the current look and feel.titleColor
- the color for the title text, ornull
to use a default from the current look and feel.
- Throws:
IllegalArgumentException
- iftitleJustification
ortitlePosition
have an unsupported value.
public Border getBorder()
Retrieves the border underneath the title. If no border has been set, or if it has been set tonull
, the currentLookAndFeel
will be asked for a border using the keyTitledBorder.border
.
- Returns:
- a border, or
null
if the current LookAndFeel does not provide a border for the keyTitledBorder.border
.
- See Also:
UIManager.getBorder(Object)
public Insets getBorderInsets(Component c)
Measures the width of this border.
- Specified by:
- getBorderInsets in interface Border
- Overrides:
- getBorderInsets in interface AbstractBorder
- Parameters:
c
- the component whose border is to be measured.
- Returns:
- an Insets object whose
left
,right
,top
andbottom
fields indicate the width of the border at the respective edge.
- See Also:
getBorderInsets(Component,Insets)
public Insets getBorderInsets(Component c, Insets insets)
Measures the width of this border, storing the results into a pre-existing Insets object.
- Overrides:
- getBorderInsets in interface AbstractBorder
- Parameters:
insets
- an Insets object for holding the result values. After invoking this method, theleft
,right
,top
andbottom
fields indicate the width of the border at the respective edge.
- Returns:
- the same object that was passed for
insets
.
- See Also:
getBorderInsets(Component)
protected Font getFont(Component c)
Returns the font that is used for displaying the title text for a given Component.
- Parameters:
c
- the Component for which this TitledBorder is the border.
- Returns:
- The font returned by
getTitleFont()
, or a fallback ifgetTitleFont()
returnednull
.
public Dimension getMinimumSize(Component c)
Calculates the minimum size needed for displaying the border and its title.
- Parameters:
c
- the Component for which this TitledBorder constitutes a border.
- Returns:
- The minimum size.
public String getTitle()
Returns the text of the title.
- Returns:
- the title text, or
null
if no title is displayed.
public Color getTitleColor()
Retrieves the color for displaying the title text. If no color has been set, or if it has been set tonull
, the currentLookAndFeel
will be asked for a color using the keyTitledBorder.titleColor
.
- Returns:
- a color, or
null
if the current LookAndFeel does not provide a color for the keyTitledBorder.titleColor
.
- See Also:
UIManager.getColor(Object)
public Font getTitleFont()
Retrieves the font for displaying the title text. If no font has been set, or if it has been set tonull
, the currentLookAndFeel
will be asked for a font using the keyTitledBorder.font
.
- Returns:
- a font, or
null
if the current LookAndFeel does not provide a font for the keyTitledBorder.font
.
- See Also:
UIManager.getFont(Object)
public int getTitleJustification()
Returns the horizontal alignment of the title text in relation to the border.
public int getTitlePosition()
Returns the vertical position of the title text in relation to the border.
- Returns:
- one of the values
ABOVE_TOP
,TOP
,BELOW_TOP
,ABOVE_BOTTOM
,BOTTOM
,BELOW_BOTTOM
, orDEFAULT_POSITION
.
public boolean isBorderOpaque()
Returnsfalse
, indicating that there are pixels inside the area of this border where the background shines through.
- Specified by:
- isBorderOpaque in interface Border
- Overrides:
- isBorderOpaque in interface AbstractBorder
- Returns:
false
.
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
Paints the border and the title text.
- Specified by:
- paintBorder in interface Border
- Overrides:
- paintBorder in interface AbstractBorder
- Parameters:
c
- the component whose border is to be painted.g
- the graphics for painting.x
- the horizontal position for painting the border.y
- the vertical position for painting the border.width
- the width of the available area for painting the border.height
- the height of the available area for painting the border.
public void setBorder(Border border)
Sets the border underneath the title.
- Parameters:
border
- a border, ornull
to use the border that is supplied by the current LookAndFeel.
- See Also:
getBorder()
public void setTitle(String title)
Sets the text of the title.
- Parameters:
title
- the new title text, ornull
for displaying no text at all.
public void setTitleColor(Color titleColor)
Sets the color for displaying the title text.
- Parameters:
titleColor
- the color, ornull
to use the color provided by the currentLookAndFeel
.
- See Also:
getTitleColor()
public void setTitleFont(Font titleFont)
Sets the font for displaying the title text.
- Parameters:
titleFont
- the font, ornull
to use the font provided by the currentLookAndFeel
.
- See Also:
getTitleFont()
public void setTitleJustification(int titleJustification)
Sets the horizontal alignment of the title text in relation to the border.
- Throws:
IllegalArgumentException
- if an unsupported value is passed fortitleJustification
.
public void setTitlePosition(int titlePosition)
Sets the vertical position of the title text in relation to the border.
- Parameters:
titlePosition
- one of the valuesABOVE_TOP
,TOP
,BELOW_TOP
,ABOVE_BOTTOM
,BOTTOM
,BELOW_BOTTOM
, orDEFAULT_POSITION
.
- Throws:
IllegalArgumentException
- if an unsupported value is passed fortitlePosition
.