Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Quick question. How to change color?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xHoly-Divinity




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Mon Sep 12, 2005 6:15 pm   Post subject: (No 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);
xHoly-Divinity




PostPosted: Mon Sep 12, 2005 6:18 pm   Post subject: (No subject)

Thank You! Smile
1of42




PostPosted: Mon Sep 12, 2005 10:01 pm   Post subject: (No 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.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: