This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.border
class TitledBorder

java.lang.Object extended by javax.swing.border.AbstractBorder extended by javax.swing.border.TitledBorder
All Implemented Interfaces:
Serializable, Border
Direct Known Subclasses:
BorderUIResource.TitledBorderUIResource

Most common way to construct:

TitledBorder topBorder = BorderFactory.createTitledBorder("Top");

Based on 38 examples


public class TitledBorder
extends AbstractBorder

A class which implements an arbitrary border with the addition of a String title in a specified position and justification.

If the border, font, or color property values are not specified in the constuctor 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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.


Field Summary
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 Summary

          Creates a TitledBorder instance with the specified border and an empty title.
TitledBorder(Border border, String title)

          Creates a TitledBorder instance with the specified border and title.
TitledBorder(Border border, String title, int titleJustification, int titlePosition)

          Creates a TitledBorder instance with the specified border, title, title-justification, and title-position.
TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont)

          Creates a TitledBorder instance with the specified border, title, title-justification, title-position, and title-font.
TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)

          Creates a TitledBorder instance with the specified border, title, title-justification, title-position, title-font, and title-color.

          Creates a TitledBorder instance.
 
Method Summary
 int
getBaseline(Component c, int width, int height)

          Returns the baseline.
 Component.BaselineResizeBehavior

          Returns an enum indicating how the baseline of the border changes as the size changes.
 Border

          Returns the border of the titled border.
 Insets

          Returns the insets of the border.
 Insets

          Reinitialize the insets parameter with this Border's current Insets.
protected Font

          
 Dimension

          Returns the minimum dimensions this border requires in order to fully display the border and title.
 String

          Returns the title of the titled border.
 Color

          Returns the title-color of the titled border.
 Font

          Returns the title-font of the titled border.
 int

          Returns the title-justification of the titled border.
 int

          Returns the title-position of the titled border.
 boolean

          Returns whether or not the border is opaque.
 void
paintBorder(Component c, Graphics g, int x, int y, int width, int height)

          Paints the border for the specified component with the specified position and size.
 void
setBorder(Border border)

          Sets the border of the titled border.
 void

          Sets the title of the titled border.
 void
setTitleColor(Color titleColor)

          Sets the title-color of the titled border.
 void
setTitleFont(Font titleFont)

          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.
 
Methods inherited from class javax.swing.border.AbstractBorder
getBaseline, getBaselineResizeBehavior, getBorderInsets, getBorderInsets, getInteriorRectangle, getInteriorRectangle, isBorderOpaque, paintBorder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABOVE_BOTTOM

public static final int ABOVE_BOTTOM
Position the title above the border's bottom line.

ABOVE_TOP

public static final int ABOVE_TOP
Position the title above the border's top line.

BELOW_BOTTOM

public static final int BELOW_BOTTOM
Position the title below the border's bottom line.

BELOW_TOP

public static final int BELOW_TOP
Position the title below the border's top line.

border

protected Border border

BOTTOM

public static final int BOTTOM
Position the title in the middle of the border's bottom line.

CENTER

public static final int CENTER
Position title text in the center of the border line.

DEFAULT_JUSTIFICATION

public static final int DEFAULT_JUSTIFICATION
Use the default justification for the title text.

DEFAULT_POSITION

public static final int DEFAULT_POSITION
Use the default vertical orientation for the title text.

EDGE_SPACING

protected static final int EDGE_SPACING

LEADING

public static final 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.

LEFT

public static final int LEFT
Position title text at the left side of the border line.

RIGHT

public static final int RIGHT
Position title text at the right side of the border line.

TEXT_INSET_H

protected static final int TEXT_INSET_H

TEXT_SPACING

protected static final int TEXT_SPACING

title

protected String title

titleColor

protected Color titleColor

titleFont

protected Font titleFont

titleJustification

protected int titleJustification

titlePosition

protected int titlePosition

TOP

public static final int TOP
Position the title in the middle of the border's top line.

TRAILING

public static final 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 Detail

TitledBorder

public TitledBorder(Border border)
Creates a TitledBorder instance with the specified border and an empty title.

Parameters:
border - the border

TitledBorder

public TitledBorder(Border border,
                    String title)
Creates a TitledBorder instance with the specified border and title.

Parameters:
border - the border
title - the title the border should display

TitledBorder

public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition)
Creates a TitledBorder instance with the specified border, title, title-justification, and title-position.

Parameters:
border - the border
title - the title the border should display
titleJustification - the justification for the title
titlePosition - the position for the title

TitledBorder

public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont)
Creates a TitledBorder instance with the specified border, title, title-justification, title-position, and title-font.

Parameters:
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

TitledBorder

public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor)
Creates a TitledBorder instance with the specified border, title, title-justification, title-position, title-font, and title-color.

Parameters:
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

TitledBorder

public TitledBorder(String title)
Creates a TitledBorder instance.

Parameters:
title - the title the border should display
Method Detail

getBaseline

public int getBaseline(Component c,
                       int width,
                       int height)
Returns the baseline.

Overrides:
getBaseline in class AbstractBorder
Parameters:
c
width
height

getBaselineResizeBehavior

public Component.BaselineResizeBehavior getBaselineResizeBehavior(Component c)
Returns an enum indicating how the baseline of the border changes as the size changes.

Overrides:
getBaselineResizeBehavior in class AbstractBorder
Parameters:
c

getBorder

public Border getBorder()
Returns the border of the titled border.


getBorderInsets

public Insets getBorderInsets(Component c)
Returns the insets of the border.

Overrides:
getBorderInsets in class AbstractBorder
Parameters:
c - the component for which this border insets value applies

getBorderInsets

public Insets getBorderInsets(Component c,
                              Insets insets)
Reinitialize the insets parameter with this Border's current Insets.

Overrides:
getBorderInsets in class AbstractBorder
Parameters:
c - the component for which this border insets value applies
insets - the object to be reinitialized

getFont

protected Font getFont(Component c)
Parameters:
c

getMinimumSize

public Dimension getMinimumSize(Component c)
Returns the minimum dimensions this border requires in order to fully display the border and title.

Parameters:
c - the component where this border will be drawn

getTitle

public String getTitle()
Returns the title of the titled border.


getTitleColor

public Color getTitleColor()
Returns the title-color of the titled border.


getTitleFont

public Font getTitleFont()
Returns the title-font of the titled border.


getTitleJustification

public int getTitleJustification()
Returns the title-justification of the titled border.


getTitlePosition

public int getTitlePosition()
Returns the title-position of the titled border.


isBorderOpaque

public boolean isBorderOpaque()
Returns whether or not the border is opaque.

Overrides:
isBorderOpaque in class AbstractBorder

paintBorder

public void paintBorder(Component c,
                        Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
Paints the border for the specified component with the specified position and size.

Overrides:
paintBorder in class AbstractBorder
Parameters:
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

setBorder

public void setBorder(Border border)
Sets the border of the titled border.

Parameters:
border - the border

setTitle

public void setTitle(String title)
Sets the title of the titled border. param title the title for the border

Parameters:
title

setTitleColor

public void setTitleColor(Color titleColor)
Sets the title-color of the titled border.

Parameters:
titleColor - the color for the border title

setTitleFont

public void setTitleFont(Font titleFont)
Sets the title-font of the titled border.

Parameters:
titleFont - the font for the border title

setTitleJustification

public void setTitleJustification(int titleJustification)
Sets the title-justification of the titled border.

Parameters:
titleJustification - the justification for the border

setTitlePosition

public void setTitlePosition(int titlePosition)
Sets the title-position of the titled border.

Parameters:
titlePosition - the position for the border


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.