org.xulux.guilayer.swing.extensions
Class IconTitledBorder

java.lang.Object
  extended by javax.swing.border.AbstractBorder
      extended by org.xulux.guilayer.swing.extensions.IconTitledBorder
All Implemented Interfaces:
java.io.Serializable, javax.swing.border.Border

public class IconTitledBorder
extends javax.swing.border.AbstractBorder

A border wich supports an icon as well as text.

Version:
$Id: IconTitledBorder.java,v 1.1 2005/12/18 12:58:18 mvdb Exp $
Author:
Martin van den Bemt
See Also:
Serialized Form

Field Summary
static int EDGE_SPACING
           
protected  javax.swing.ImageIcon image
           
static int TEXTICON_SPACING
           
protected  int thickness
           
protected  java.lang.String title
           
static int TITLE_SPACING
           
 
Constructor Summary
IconTitledBorder()
           
 
Method Summary
protected  void clearLineForTitle(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
           
 java.awt.Insets getBorderInsets(java.awt.Component c)
           
 java.awt.Insets getBorderInsets(java.awt.Component c, java.awt.Insets insets)
           
 javax.swing.ImageIcon getImage()
           
protected  int getLineCorrection(java.awt.Component c)
           
 int getMaxHeight(java.awt.Component c)
           
 int getThickness()
           
 java.lang.String getTitle()
           
protected  java.awt.Rectangle getTitleRectangle(java.awt.Component c, int x, int y, int width)
           
 int getTitleWidth(java.awt.Component c)
           
 void paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
           
protected  void paintImage(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
           
protected  void paintTitle(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
           
 void setImage(java.awt.Image image)
          Set the image of the border.
 void setThickness(int thickness)
           
 void setTitle(java.lang.String string)
           
 
Methods inherited from class javax.swing.border.AbstractBorder
getBaseline, getBaselineResizeBehavior, getInteriorRectangle, getInteriorRectangle, isBorderOpaque
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDGE_SPACING

public static final int EDGE_SPACING
See Also:
Constant Field Values

TITLE_SPACING

public static final int TITLE_SPACING
See Also:
Constant Field Values

TEXTICON_SPACING

public static final int TEXTICON_SPACING
See Also:
Constant Field Values

thickness

protected int thickness

title

protected java.lang.String title

image

protected javax.swing.ImageIcon image
Constructor Detail

IconTitledBorder

public IconTitledBorder()
Method Detail

paintBorder

public void paintBorder(java.awt.Component c,
                        java.awt.Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
Specified by:
paintBorder in interface javax.swing.border.Border
Overrides:
paintBorder in class javax.swing.border.AbstractBorder
See Also:
Border.paintBorder(java.awt.Component, java.awt.Graphics, int, int, int, int)

clearLineForTitle

protected void clearLineForTitle(java.awt.Component c,
                                 java.awt.Graphics g,
                                 int x,
                                 int y,
                                 int width,
                                 int height)

getTitleRectangle

protected java.awt.Rectangle getTitleRectangle(java.awt.Component c,
                                               int x,
                                               int y,
                                               int width)
Parameters:
c - the component
x - the x position
y - the y position
width - the width of the paint area
Returns:
a rectangle containing the dimensions of the title including image.

paintTitle

protected void paintTitle(java.awt.Component c,
                          java.awt.Graphics g,
                          int x,
                          int y,
                          int width,
                          int height)

getTitleWidth

public int getTitleWidth(java.awt.Component c)

paintImage

protected void paintImage(java.awt.Component c,
                          java.awt.Graphics g,
                          int x,
                          int y,
                          int width,
                          int height)

getLineCorrection

protected int getLineCorrection(java.awt.Component c)
Parameters:
c - the component to get the metric from
Returns:
the correction that needs to take place based on the icon and title for drawing a line. It will return the y correction so the line can be drawn in the middle of those components

getMaxHeight

public int getMaxHeight(java.awt.Component c)

getImage

public javax.swing.ImageIcon getImage()
Returns:
the image

getThickness

public int getThickness()
Returns:
the thickness

getTitle

public java.lang.String getTitle()
Returns:
the title of the border

setImage

public void setImage(java.awt.Image image)
Set the image of the border.

Parameters:
image - the image to use

setThickness

public void setThickness(int thickness)
Parameters:
thickness -

setTitle

public void setTitle(java.lang.String string)
Parameters:
string -

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c)
Specified by:
getBorderInsets in interface javax.swing.border.Border
Overrides:
getBorderInsets in class javax.swing.border.AbstractBorder
See Also:
Border.getBorderInsets(java.awt.Component)

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c,
                                       java.awt.Insets insets)
Overrides:
getBorderInsets in class javax.swing.border.AbstractBorder
See Also:
AbstractBorder.getBorderInsets(java.awt.Component, java.awt.Insets)


Copyright © 2002-2007 Martin van den Bemt. All Rights Reserved.