Applet, not change color!
This code works fine, but it does not seem to change the color when
requested. Thanks in advance
for any help
import java.awt.*;
public class Pattern
{
private int width,x,y;
private Color hColor, vColor;
public Pattern(int x, int y, int width, Color hColour, Color
vColour)
{
this.width = width;
this.x = x;
this.y = y;
this.hColor = hColor;
this.vColor = vColor;
}
public void draw(Graphics g)
{
int origionalX = x, origionalY = y;
int xGap = width/10;
int yGap = width/10;
for(int i = 0; i < 10; i++)
{
g.setColor(hColor);
g.drawLine(x,y,x + width,y);
y += yGap;
}
x = origionalX;
y = origionalY;
for(int i = 0; i < 10; i++)
{
g.setColor(vColor);
g.drawLine(x,y,x,y + width);
x += xGap;
}
x = origionalX;
y = origionalY;
g.drawRect(x,y,width,width);
}
}
import java.applet.Applet;
public class Quilt extends Applet
{
public void init()
{
;
}
public void paint(Graphics g)
{
Pattern p = new Pattern(10,10,50,Color.green,Color.blue);
p.draw(g);
}
}