javax.swing.border
Class TitledBorder
- Border, Serializable
A border that paints a title on top of another border.
static int | ABOVE_BOTTOM - A value for the
titlePosition property that vertically
positions the title text above the bottom line of the border.
|
static int | ABOVE_TOP - A value for the
titlePosition property that vertically
positions the title text above the top line of the border.
|
static int | BELOW_BOTTOM - A value for the
titlePosition property that vertically
positions the title text below the bottom line of the border.
|
static int | BELOW_TOP - A value for the
titlePosition property that vertically
positions the title text below the top line of the border.
|
static int | BOTTOM - A value for the
titlePosition property that vertically
positions the title text at the center of the bottom line
of the border.
|
static int | CENTER - A value for the
titleJustification property that
horizontally aligns the title text with the center of the border.
|
static int | DEFAULT_JUSTIFICATION - A value for the
titleJustification 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.
|
static int | DEFAULT_POSITION - A value for the
titlePosition property that vertically
positions the title text at the default vertical position, which
is in the middle of the top line of the border.
|
protected static int | EDGE_SPACING - The number of pixels between the inside of
border
and the bordered component.
|
static int | LEADING - A value for the
titleJustification 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.
|
static int | LEFT - A value for the
titleJustification property that
horizontally aligns the title text with the left-hand edge of
the border.
|
static int | RIGHT - A value for the
titleJustification property that
horizontally aligns the title text with the right-hand edge of
the border.
|
protected static 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.
|
protected static int | TEXT_SPACING - The number of pixels between the title text and
border .
|
static int | TOP - A value for the
titlePosition property that vertically
positions the title text at the middle of the top line
of the border.
|
static int | TRAILING - A value for the
titleJustification 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.
|
protected Border | border - The border underneath the title.
|
protected String | title - The title, or
null to display no title.
|
protected Color | titleColor - The color for displaying the title text.
|
protected Font | titleFont - The font for displaying the title text.
|
protected int | titleJustification - The horizontal alignment of the title text in relation to the
border, which is one of
LEFT , CENTER , RIGHT , LEADING , TRAILING , or DEFAULT_JUSTIFICATION .
|
protected int | titlePosition - The vertical position of the title text relative to the border,
which is one of
ABOVE_TOP , TOP , BELOW_TOP , ABOVE_BOTTOM , BOTTOM , BELOW_BOTTOM , or DEFAULT_POSITION .
|
TitledBorder(String title) - Constructs a TitledBorder given the text of its title.
|
TitledBorder(Border border) - Constructs an initially untitled TitledBorder given another border.
|
TitledBorder(Border border, String title) - Constructs a TitledBorder given its border and title text.
|
TitledBorder(Border border, String title, int titleJustification, int titlePosition) - Constructs a TitledBorder given its border, title text, horizontal
alignment, and vertical position.
|
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.
|
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.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
ABOVE_BOTTOM
public static final int ABOVE_BOTTOM
A value for the titlePosition
property that vertically
positions the title text above the bottom line of the border.
ABOVE_TOP
public static final int ABOVE_TOP
A value for the titlePosition
property that vertically
positions the title text above the top line of the border.
BELOW_BOTTOM
public static final int BELOW_BOTTOM
A value for the titlePosition
property that vertically
positions the title text below the bottom line of the border.
BELOW_TOP
public static final int BELOW_TOP
A value for the titlePosition
property that vertically
positions the title text below the top line of the border.
BOTTOM
public static final int BOTTOM
A value for the titlePosition
property that vertically
positions the title text at the center of the bottom line
of the border.
CENTER
public static final int CENTER
A value for the titleJustification
property that
horizontally aligns the title text with the center of the border.
DEFAULT_JUSTIFICATION
public static final int DEFAULT_JUSTIFICATION
A value for the
titleJustification
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 with
LEADING
.
DEFAULT_POSITION
public static final int DEFAULT_POSITION
A value for the titlePosition
property that vertically
positions the title text at the default vertical position, which
is in the middle of the top line of the border.
EDGE_SPACING
protected static final int EDGE_SPACING
The number of pixels between the inside of
border
and the bordered component.
LEADING
public static final int LEADING
A value for the
titleJustification
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 with
DEFAULT_JUSTIFICATION
.
LEFT
public static final int LEFT
A value for the titleJustification
property that
horizontally aligns the title text with the left-hand edge of
the border.
RIGHT
public static final int RIGHT
A value for the titleJustification
property that
horizontally aligns the title text with the right-hand edge of
the border.
TEXT_INSET_H
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.
TOP
public static final int TOP
A value for the titlePosition
property that vertically
positions the title text at the middle of the top line
of the border.
TRAILING
public static final int TRAILING
A value for the titleJustification
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.
border
protected Border border
The border underneath the title. If this value is
null
, the border will be retrieved from the
UIManager
’s defaults table using the key
TitledBorder.border
.
title
protected String title
The title, or null
to display no title.
titleColor
protected Color titleColor
The color for displaying the title text. If this value is
null
, the color will be retrieved from the
UIManager
’s defaults table using the key
TitledBorder.titleColor
.
titleFont
protected Font titleFont
The font for displaying the title text. If this value is
null
, the font will be retrieved from the
UIManager
’s defaults table using the key
TitledBorder.font
.
TitledBorder
public TitledBorder(String title)
Constructs a TitledBorder given the text of its title.
title
- the title text, or null
to use no title text.
TitledBorder
public TitledBorder(Border border)
Constructs an initially untitled TitledBorder given another border.
border
- the border underneath the title, or null
to use a default from the current look and feel.
TitledBorder
public TitledBorder(Border border,
String title)
Constructs a TitledBorder given its border and title text.
border
- the border underneath the title, or null
to use a default from the current look and feel.title
- the title text, or null
to use no title
text.
TitledBorder
public TitledBorder(Border border,
String title,
int titleJustification,
int titlePosition)
Constructs a TitledBorder given its border, title text, horizontal
alignment, and vertical position.
border
- the border underneath the title, or null
to use a default from the current look and feel.title
- the title text, or null
to use no title
text.titleJustification
- the horizontal alignment of the title
text in relation to the border. The value must be one of
LEFT
, CENTER
, RIGHT
, LEADING
,
TRAILING
, or DEFAULT_JUSTIFICATION
.titlePosition
- the vertical position of the title text
in relation to the border. The value must be one of
ABOVE_TOP
, TOP
, BELOW_TOP
,
ABOVE_BOTTOM
, BOTTOM
, BELOW_BOTTOM
,
or DEFAULT_POSITION
.
TitledBorder
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.
border
- the border underneath the title, or null
to use a default from the current look and feel.title
- the title text, or null
to use no title
text.titleJustification
- the horizontal alignment of the title
text in relation to the border. The value must be one of
LEFT
, CENTER
, RIGHT
, LEADING
,
TRAILING
, or DEFAULT_JUSTIFICATION
.titlePosition
- the vertical position of the title text
in relation to the border. The value must be one of
ABOVE_TOP
, TOP
, BELOW_TOP
,
ABOVE_BOTTOM
, BOTTOM
, BELOW_BOTTOM
,
or DEFAULT_POSITION
.titleFont
- the font for the title text, or null
to use a default from the current look and feel.
TitledBorder
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.
border
- the border underneath the title, or null
to use a default from the current look and feel.title
- the title text, or null
to use no title
text.titleJustification
- the horizontal alignment of the title
text in relation to the border. The value must be one of
LEFT
, CENTER
, RIGHT
, LEADING
,
TRAILING
, or DEFAULT_JUSTIFICATION
.titlePosition
- the vertical position of the title text
in relation to the border. The value must be one of
ABOVE_TOP
, TOP
, BELOW_TOP
,
ABOVE_BOTTOM
, BOTTOM
, BELOW_BOTTOM
,
or DEFAULT_POSITION
.titleFont
- the font for the title text, or null
to use a default from the current look and feel.titleColor
- the color for the title text, or null
to use a default from the current look and feel.
getBorder
public Border getBorder()
Retrieves the border underneath the title. If no border has been
set, or if it has been set to
null
, the current
LookAndFeel
will be asked for a border
using the key
TitledBorder.border
.
- a border, or
null
if the current LookAndFeel
does not provide a border for the key
TitledBorder.border
.
getBorderInsets
public Insets getBorderInsets(Component c,
Insets insets)
Measures the width of this border, storing the results into a
pre-existing Insets object.
- getBorderInsets in interface AbstractBorder
insets
- an Insets object for holding the result values.
After invoking this method, the left
,
right
, top
and
bottom
fields indicate the width of the
border at the respective edge.
- the same object that was passed for
insets
.
getFont
protected Font getFont(Component c)
Returns the font that is used for displaying the title text for
a given Component.
c
- the Component for which this TitledBorder is the border.
getMinimumSize
public Dimension getMinimumSize(Component c)
Calculates the minimum size needed for displaying the border
and its title.
c
- the Component for which this TitledBorder constitutes
a border.
getTitle
public String getTitle()
Returns the text of the title.
- the title text, or
null
if no title is
displayed.
getTitleColor
public Color getTitleColor()
Retrieves the color for displaying the title text. If no color has
been set, or if it has been set to
null
, the current
LookAndFeel
will be asked for a color
using the key
TitledBorder.titleColor
.
- a color, or
null
if the current LookAndFeel
does not provide a color for the key
TitledBorder.titleColor
.
getTitleFont
public Font getTitleFont()
Retrieves the font for displaying the title text. If no font has
been set, or if it has been set to
null
, the current
LookAndFeel
will be asked for a font
using the key
TitledBorder.font
.
- a font, or
null
if the current LookAndFeel
does not provide a font for the key
TitledBorder.font
.
getTitleJustification
public int getTitleJustification()
Returns the horizontal alignment of the title text in relation to
the border.
getTitlePosition
public int getTitlePosition()
Returns the vertical position of the title text in relation
to the border.
paintBorder
public void paintBorder(Component c,
Graphics g,
int x,
int y,
int width,
int height)
Paints the border and the title text.
- paintBorder in interface Border
- paintBorder in interface AbstractBorder
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.
setBorder
public void setBorder(Border border)
Sets the border underneath the title.
border
- a border, or null
to use the
border that is supplied by the current LookAndFeel.
setTitle
public void setTitle(String title)
Sets the text of the title.
title
- the new title text, or null
for displaying
no text at all.
setTitleColor
public void setTitleColor(Color titleColor)
Sets the color for displaying the title text.
titleColor
- the color, or null
to use the color
provided by the current LookAndFeel
.
setTitleFont
public void setTitleFont(Font titleFont)
Sets the font for displaying the title text.
titleFont
- the font, or null
to use the font
provided by the current LookAndFeel
.
setTitleJustification
public void setTitleJustification(int titleJustification)
Sets the horizontal alignment of the title text in relation to the border.
setTitlePosition
public void setTitlePosition(int titlePosition)
Sets the vertical position of the title text in relation
to the border.
TitledBorder.java --
Copyright (C) 2003, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.