FileDocCategorySizeDatePackage
SynthBorder.javaAPI DocJava SE 5 API4187Fri Aug 26 14:58:10 BST 2005javax.swing.plaf.synth

SynthBorder

public class SynthBorder extends AbstractBorder implements UIResource
SynthBorder is a border that delegates to a Painter. The Insets are determined at construction time.
version
1.12, 12/19/03
author
Scott Violet

Fields Summary
private sun.swing.plaf.synth.SynthUI
ui
private Insets
insets
Constructors Summary
SynthBorder(sun.swing.plaf.synth.SynthUI ui, Insets insets)

        this.ui = ui;
        this.insets = insets;
    
SynthBorder(sun.swing.plaf.synth.SynthUI ui)

        this(ui, null);
    
Methods Summary
public java.awt.InsetsgetBorderInsets(java.awt.Component c)
This default implementation returns a new Insets instance where the top, left, bottom, and right fields are set to 0.

param
c the component for which this border insets value applies
return
the new Insets object initialized to 0

 
        return getBorderInsets(c, null);
    
public java.awt.InsetsgetBorderInsets(java.awt.Component c, java.awt.Insets insets)
Reinitializes the insets parameter with this Border's current Insets.

param
c the component for which this border insets value applies
param
insets the object to be reinitialized
return
the insets object

        if (this.insets != null) {
            if (insets == null) {
                insets = new Insets(this.insets.top, this.insets.left,
                                  this.insets.bottom, this.insets.right);
            }
            else {
                insets.top = this.insets.top;
                insets.bottom = this.insets.bottom;
                insets.left = this.insets.left;
                insets.right = this.insets.left;
            }
        }
        else if (insets == null) {
            insets = new Insets(0, 0, 0, 0);
        }
        else {
            insets.top = insets.bottom = insets.left = insets.right = 0;
        }
        if (c instanceof JComponent) {
            Region region = Region.getRegion((JComponent)c);
            Insets margin = null;
            if ((region == Region.ARROW_BUTTON || region == Region.BUTTON ||
                 region == Region.CHECK_BOX ||
                 region == Region.CHECK_BOX_MENU_ITEM ||
                 region == Region.MENU || region == Region.MENU_ITEM ||
                 region == Region.RADIO_BUTTON ||
                 region == Region.RADIO_BUTTON_MENU_ITEM ||
                 region == Region.TOGGLE_BUTTON) &&
                       (c instanceof AbstractButton)) {
                margin = ((AbstractButton)c).getMargin();
            }
            else if (region == Region.TOOL_BAR && (c instanceof JToolBar)) {
                margin = ((JToolBar)c).getMargin();
            }
            else if (region == Region.MENU_BAR && (c instanceof JMenuBar)) {
                margin = ((JMenuBar)c).getMargin();
            }
            if (margin != null) {
                insets.top += margin.top;
                insets.bottom += margin.bottom;
                insets.left += margin.left;
                insets.right += margin.right;
            }
        }
        return insets;
    
public booleanisBorderOpaque()
This default implementation returns false.

return
false

        return false;
    
public voidpaintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)

        JComponent jc = (JComponent)c;
        SynthContext context = ui.getContext(jc);
        SynthStyle style = context.getStyle();
        if (style == null) {
            assert false: "SynthBorder is being used outside after the UI " +
                          "has been uninstalled";
            return;
        }
        ui.paintBorder(context, g, x, y, width, height);
        context.dispose();