FileDocCategorySizeDatePackage
TiledImageComponent.javaAPI DocExample1616Sat Oct 27 15:57:16 BST 2001None

TiledImageComponent

public class TiledImageComponent extends Container
Demo of Tiled Image
version
$Id: TiledImageComponent.java,v 1.3 2001/10/27 18:57:17 ian Exp $
author
Ian F. Darwin, ian@darwinsys.com

Fields Summary
TextField
nameTF
TextField
passTF
TextField
domainTF
Image
im
String
IMAGE_NAME
Constructors Summary
public TiledImageComponent()
Set things up nicely.


	     
	  
		Label l;

		setLayout(new FlowLayout());
		add(l = new Label("Name:", Label.CENTER));
		add(nameTF=new TextField(10));

		add(l = new Label("Password:", Label.CENTER));
		add(passTF=new TextField(10));
		passTF.setEchoChar('*");

		add(l = new Label("Domain:", Label.CENTER));
		add(domainTF=new TextField(10));

		im = getToolkit().getImage(IMAGE_NAME);
	
Methods Summary
public static voidmain(java.lang.String[] av)

		Frame f = new Frame("TiledImageComponent Demo");
		f.add(new TiledImageComponent());
		f.setSize(200, 200);
		f.setVisible(true);
		f.addWindowListener(new WindowCloser(f, true));
	
public voidpaint(java.awt.Graphics g)
paint() - just tile the background.

		// System.out.println("In paint()");
		if (im == null)
			return;
		int iw = im.getWidth(this), ih=im.getHeight(this);
		if (iw < 0 || ih < 0)	// image not ready
			return;				// live to try again later.
		int w = getSize().width, h = getSize().height;
		// System.out.println(iw + "," + ih + "; " + w + ", " + h);
		for (int i = 0; i<=w; i+=iw) {
			for (int j = 0; j<=h; j+=ih) {
				// System.out.println("drawImage(im,"+i+","+j+")");
				g.drawImage(im, i, j, this);
			}
		}