Source Code : Flex 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

Flex Border

   

//   FlexBorder
//
//   Copyright (C) by Andrea Carboni.
//   This file may be distributed under the terms of the LGPL license.
//


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

import javax.swing.border.Border;

public class FlexBorder implements Border
{
  public static final int NONE        = 0;
  public static final int TOP_LINE    = 1;
  public static final int BOTTOM_LINE = 2;
  public static final int RECT        = 3;
  
  private Insets insets = new Insets(0,0,0,0);
  private Color  color  = Color.blue;
  private int    type   = RECT;
  
  //---------------------------------------------------------------------------

  public FlexBorder()
  {
  }
  
  //---------------------------------------------------------------------------
  
  public FlexBorder(Color c, int t)
  {
    color = c;
    type  = t;
  }

  //---------------------------------------------------------------------------

  public void setColor(Color c)
  {
    color = c;
  }
  
  //---------------------------------------------------------------------------
  
  public void setType(int t)
  {
    type = t;
  }
    
  //---------------------------------------------------------------------------
  //---
  //---   Border interface methods
  //---
  //---------------------------------------------------------------------------

  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
  {
    g.setColor(color);
    
    switch(type)
    {
      case TOP_LINE:    g.drawLine(x,y, x+width-1, y);
                  break;

      case BOTTOM_LINE: g.drawLine(x,y+height-1, x+width-1, y+height-1);
                  break;
        
      case RECT:      g.drawRect(x, y, width-1, height-1);
                  break;
    }
  }

  //---------------------------------------------------------------------------

  public Insets getBorderInsets(Component c)
  {
    return insets;
  }

  //---------------------------------------------------------------------------

  public boolean isBorderOpaque() { return false; }
}

//

   
    
    
  

Thank with us