Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.swing.plaf.basic
Class BasicBorders.MarginBorder  view BasicBorders.MarginBorder download BasicBorders.MarginBorder.java

java.lang.Object
  extended byjavax.swing.border.AbstractBorder
      extended byjavax.swing.plaf.basic.BasicBorders.MarginBorder
All Implemented Interfaces:
javax.swing.border.Border, java.io.Serializable, javax.swing.plaf.UIResource
Enclosing class:
BasicBorders

public static class BasicBorders.MarginBorder
extends javax.swing.border.AbstractBorder
implements java.io.Serializable, javax.swing.plaf.UIResource

An invisible, but spacing border whose margin is determined by calling the getMargin() method of the enclosed component. If the enclosed component has no such method, this border will not occupy any space.

[An illustration that shows how MarginBorder
 determines its borders]


Field Summary
(package private) static long serialVersionUID
          Determined using the serialver tool of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
 
Constructor Summary
BasicBorders.MarginBorder()
          Constructs a new MarginBorder.
 
Method Summary
 java.awt.Insets getBorderInsets(java.awt.Component c)
          Measures the width of this border.
 java.awt.Insets getBorderInsets(java.awt.Component c, java.awt.Insets insets)
          Determines the insets of this border by calling the getMargin() method of the enclosed component.
 
Methods inherited from class javax.swing.border.AbstractBorder
getInteriorRectangle, getInteriorRectangle, isBorderOpaque, paintBorder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
Determined using the serialver tool of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.

See Also:
Constant Field Values
Constructor Detail

BasicBorders.MarginBorder

public BasicBorders.MarginBorder()
Constructs a new MarginBorder.

Method Detail

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c)
Measures the width of this border.

Specified by:
getBorderInsets in interface javax.swing.border.Border

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c,
                                       java.awt.Insets insets)
Determines the insets of this border by calling the getMargin() method of the enclosed component. The resulting margin will be stored into the the left, right, top and bottom fields of the passed insets parameter.

Unfortunately, getMargin() is not a method of javax.swing.JComponent or some other common superclass of things with margins. While reflection could be used to determine the existence of this method, this would be slow on many virtual machines. Therefore, the current implementation knows about AbstractButton.getMargin()>AbstractButton.getMargin() 55 , JPopupMenu.getMargin()>JPopupMenu.getMargin() 55 , JToolBar.getMargin()>JToolBar.getMargin() 55 , and javax.swing.text.JTextComponent. If c is an instance of a known class, the respective getMargin() method is called to determine the correct margin. Otherwise, a zero-width margin is returned.