FileDocCategorySizeDatePackage
ColorDisplay.javaAPI DocExample2002Mon Mar 24 02:02:12 GMT 1997None

ColorDisplay

public class ColorDisplay extends Frame

Fields Summary
int
width
int
height
static Color[]
colors
Constructors Summary
ColorDisplay()

      
        super ("ColorDisplay");
        setBackground (Color.white);
    
Methods Summary
public booleankeyDown(java.awt.Event e, int c)

        for (int i=0;i<colors.length;i++)
            colors[i] = colors[i].darker();
        repaint();
        System.out.println ("Help");
        return true;
    
public static voidmain(java.lang.String[] args)

        ColorDisplay f = new ColorDisplay();
        f.resize (300,300);
        f.show();
    
public booleanmouseDown(java.awt.Event e, int x, int y)

        for (int i=0;i<colors.length;i++)
            colors[i] = colors[i].brighter();
        repaint();
        System.out.println ("ClickCount: " + e.clickCount);
        System.out.println (e.modifiers);
        return true;
    
public voidpaint(java.awt.Graphics g)

        g.translate(insets().left, insets().top);
        if (width == 0) {
            Insets inset = insets();
            width  = (size().width - inset.right - inset.left) / 3;
            height = (size().height - inset.top - inset.bottom) / 5;
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 5; j++) {
                if ((i == 2) && (j >= 3)) break;
                g.setColor (colors[i*5+j]);
                g.fillRect (i*width, j*height, width, height);
            }
        }