Source Code : Right border

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Right border

  
//com.amkai.borders;

import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Color;
import java.awt.Component;

import javax.swing.border.AbstractBorder;

public class RightSideBorder extends AbstractBorder
{
    protected int thickness;
    protected Color lineColor;
    protected int gap;

    public RightSideBorder(Color color) {
        this(color, 1, 1);
    }

    public RightSideBorder(Color color, int thickness)  {
        this(color, thickness, thickness);
    }

    public RightSideBorder(Color color, int thickness, int gap)  {
        lineColor = color;
        this.thickness = thickness;
        this.gap = gap;
    }

    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Color oldColor = g.getColor();
        int i;

        g.setColor(lineColor);
        for(i = 0; i < thickness; i++)  {
          g.drawLine(x+width-i-1, y, x+width-i-1, y+height);
        }
        g.setColor(oldColor);
    }

    /**
     * Returns the insets of the border.
     * @param c the component for which this border insets value applies
     */
    public Insets getBorderInsets(Component c)       {
        return new Insets(0, 0, 0,gap);
    }

    public Insets getBorderInsets(Component c, Insets insets) {
        insets.left = 0;
        insets.top = 0;
        insets.right = gap;
        insets.bottom = 0;
        return insets;
    }

    /**
     * Returns the color of the border.
     */
    public Color getLineColor()     {
        return lineColor;
    }

    /**
     * Returns the thickness of the border.
     */
    public int getThickness()       {
        return thickness;
    }

    /**
     * Returns whether or not the border is opaque.
     */
    public boolean isBorderOpaque() { 
        return false; 
    }

  public int getGap() {
    return gap;
  }

}

   
    
  

Thank with us