org.jdesktop.swingx.plaf
Class BuddyLayoutAndBorder

java.lang.Object
  extended by org.jdesktop.swingx.plaf.BuddyLayoutAndBorder
All Implemented Interfaces:
LayoutManager, PropertyChangeListener, EventListener, Border, UIResource

public class BuddyLayoutAndBorder
extends Object
implements LayoutManager, Border, PropertyChangeListener, UIResource


Constructor Summary
BuddyLayoutAndBorder()
           
 
Method Summary
 void addLayoutComponent(String name, Component comp)
          Does nothing.
protected  int centerY(Rectangle rect, Dimension size)
           
 Border getBorderDelegate()
           
 Insets getBorderInsets(Component c)
          Returns the Insets of the original Border plus the space required by the child components.
 Insets getRealBorderInsets()
          Returns the insets of the original border (without the margin! Beware of BasicBorders.MarginBorder!).
protected  Rectangle getVisibleRect()
           
protected  void install(JTextField textField)
          Installs a BuddyLayoutAndBorder as a layout and border of the given text field.
 boolean isBorderOpaque()
          Returns whether or not the border is opaque.
 void layoutContainer(Container parent)
          Lays out the specified container.
 Dimension minimumLayoutSize(Container parent)
          Calculates the minimum size dimensions for the specified container, given the components it contains.
 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.
 Dimension preferredLayoutSize(Container parent)
          Calculates the preferred size dimensions for the specified container, given the components it contains.
 void propertyChange(PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
 void removeLayoutComponent(Component comp)
          Does nothing.
protected  void replaceBorderIfNecessary()
          Wraps and replaces the text fields default border with this object, to honor the button margins and sizes of the search, clear and popup buttons and the layout style.
 String toString()
          Returns a string representation of the object.
 void uninstall()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BuddyLayoutAndBorder

public BuddyLayoutAndBorder()
Method Detail

install

protected void install(JTextField textField)
Installs a BuddyLayoutAndBorder as a layout and border of the given text field. Registers a PropertyChangeListener to wrap any subsequently set border on the text field.


getBorderDelegate

public Border getBorderDelegate()

replaceBorderIfNecessary

protected void replaceBorderIfNecessary()
Wraps and replaces the text fields default border with this object, to honor the button margins and sizes of the search, clear and popup buttons and the layout style.


addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Does nothing.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the string to be associated with the component
comp - the component to be added
See Also:
BuddySupport#add(javax.swing.JComponent, Position, JTextField)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Description copied from interface: java.awt.LayoutManager
Calculates the minimum size dimensions for the specified container, given the components it contains.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - the component to be laid out
See Also:
LayoutManager.preferredLayoutSize(java.awt.Container)

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Description copied from interface: java.awt.LayoutManager
Calculates the preferred size dimensions for the specified container, given the components it contains.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - the container to be laid out
See Also:
LayoutManager.minimumLayoutSize(java.awt.Container)

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Does nothing.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp - the component to be removed
See Also:
BuddySupport.remove(javax.swing.JComponent, JTextField)

layoutContainer

public void layoutContainer(Container parent)
Description copied from interface: java.awt.LayoutManager
Lays out the specified container.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - the container to be laid out

centerY

protected int centerY(Rectangle rect,
                      Dimension size)

getVisibleRect

protected Rectangle getVisibleRect()
Returns:
the rectangle allocated by the text field, including the space allocated by the child components left and right, the text fields original border insets and the outer margin.

getBorderInsets

public Insets getBorderInsets(Component c)
Returns the Insets of the original Border plus the space required by the child components.

Specified by:
getBorderInsets in interface Border
Parameters:
c - the component for which this border insets value applies
See Also:
Border.getBorderInsets(java.awt.Component)

getRealBorderInsets

public Insets getRealBorderInsets()
Returns the insets of the original border (without the margin! Beware of BasicBorders.MarginBorder!).

Returns:
the insets of the border delegate

isBorderOpaque

public boolean isBorderOpaque()
Description copied from interface: javax.swing.border.Border
Returns whether or not the border is opaque. If the border is opaque, it is responsible for filling in it's own background when painting.

Specified by:
isBorderOpaque in interface Border

paintBorder

public void paintBorder(Component c,
                        Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
Description copied from interface: javax.swing.border.Border
Paints the border for the specified component with the specified position and size.

Specified by:
paintBorder in interface Border
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

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Description copied from interface: java.beans.PropertyChangeListener
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.

uninstall

public void uninstall()

toString

public String toString()
Description copied from class: java.lang.Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.