Java Article 2 Code: GrayView.java
// GrayView.java
// By Ned Etcode
// Copyright 1995, 1996 Netscape Communications Corp. All rights reserved.
import netscape_beta.application.*;
import netscape_beta.util.*;
/** The most common way to draw to the screen is to subclass View and
* override the primitive drawing method, drawView(). In this simple example
* we just fill our bounds with a solid shade of gray.
*/
public class GrayView extends View {
int value;
public GrayView(int x, int y, int width, int height) {
super(x, y, width, height);
}
public void setValue(int value) {
this.value = value;
draw();
}
public int value() {
return value;
}
public void drawView(Graphics g) {
g.setColor(new Color(value, value, value));
g.fillRect(0, 0, width(), height());
}
}
Back to IFC article