Computer Science Canada

Quick question. How to change color?

Author:  xHoly-Divinity [ Mon Sep 12, 2005 5:56 pm ]
Post subject:  Quick question. How to change color?

code:

import java.awt.*;
import hsa.Console;

public class Blah
{
    static Console c;
   
    public static void main (String[] args)
    {
        c = new Console ();
        c.fillOval (200, 200, 100, 100);
    }
}


where the command "c.fillOval (200, 200, 100, 100);" how would I change the colour from being black to say white/green/blue/red/yellow?

Author:  Cervantes [ Mon Sep 12, 2005 6:15 pm ]
Post subject: 

If I remember correctly, you merely have to call the setColor method of the Console, providing it with one arguement:
RTP:

c.setColor(red);

Standard colours, such as red, are built in objects and you don't have to create a new Color object. If you want to use a specific colour with your own specific RGB values, you must create a new Color object:
RTP:

Color myColour = new Color(redComp, greenComp, blueComp);
c.setColor(myColour);

Author:  xHoly-Divinity [ Mon Sep 12, 2005 6:18 pm ]
Post subject: 

Thank You! Smile

Author:  1of42 [ Mon Sep 12, 2005 10:01 pm ]
Post subject: 

For the record, the built-in colors are all static members of the Color class, such as:

Color.RED, Color.BLACK, Color.BLUE etc.


: