TiledImageComponentpublic class TiledImageComponent extends Container
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 void | main(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 void | paint(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);
}
}
|
|