Source Code : Icon Line

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

Icon Line

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


import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.util.Vector;

import javax.swing.Icon;

//

public class IconLine implements Icon
{
  private int    iWidth  = 0;
  private int    iHeight = 0;
  private int    iSpace  = 1;
  private Vector vImages = new Vector();

  //---------------------------------------------------------------------------
  //---
  //--- Constructor
  //---
  //---------------------------------------------------------------------------

  public IconLine() {}

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

  public IconLine(int space)
  {
    iSpace = space;
  }

  //---------------------------------------------------------------------------
  //---
  //--- Constructor
  //---
  //---------------------------------------------------------------------------

  public void addImage(Image image)
  {
    vImages.add(image);

    iWidth  = iWidth + image.getWidth(null);
    iHeight = image.getHeight(null);
  }

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

  public void setImage(int index, Image image)
  {
    vImages.set(index, image);
    iHeight = image.getHeight(null);
  }

  //---------------------------------------------------------------------------
  //---
  //--- Icon interface methods
  //---
  //---------------------------------------------------------------------------

  public int getIconWidth()
  {
    return iWidth;
  }

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

  public int getIconHeight()
  {
    return iHeight;
  }

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

  public void paintIcon(Component c, Graphics g, int x, int y)
  {
    int dx = 0;

    for(int i=0; i<vImages.size(); i++)
    {
      Image image = (Image) vImages.get(i);

      g.drawImage(image, x +dx, y, c);
      dx += image.getWidth(c) +iSpace;
    }
  }
}

//

   
    
    
    
  

Thank with us