LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   JAVA g.setColor not working (https://www.linuxquestions.org/questions/programming-9/java-g-setcolor-not-working-679051/)

joegumbo 10-25-2008 06:57 PM

Java g.setColor not working(SOLVED!!)
 
Hi,

I'm running Sun's JDK 1.6.0_07 on Slackware 12.1 with all patches and updates applied.

I'm trying to get this assignment to work, but I keep receiving errors with my first g.setColor.

Quote:

import javax.swing.JApplet;
import java.awt.Graphics;
import java.awt.Graphics.*;
import java.awt.Color;


public class CIT130Assign3 extends JApplet
{//begin class

Color myGreen;


public void init( )
{//begin method
myGreen=new Color(38,144,96);
}//end method


public void paint (Graphics g)
{//begin method

super.paint(g);

//draw tires
g.fillOval(80,400,40,40);
g.fillOval(240,400,40,40);


//draw bottom of truck
g.setColor=(myGreen);

Never mind... i found the error...

Not
Quote:

g.setColor=(myGreen);
but
Quote:

g.setColor(myGreen);
Thanks anyhow,
-Joe

Nylex 10-26-2008 04:41 AM

//Removing from zero replies.

Two things: firstly, don't write Java as "JAVA" - it's not an acronym, so shouldn't be capitalised. Secondly, don't assume that the mods will read your post; you will need to report them if you want action taken upon them (this is moot anyway, since LQ doesn't usually delete posts).

joegumbo 10-27-2008 12:25 AM

Thank you for your advice, Nylex. I've altered my above post as much as possible to comply.

jay73 10-27-2008 12:38 AM

The setColor method is getting outdated, by the way. Nowadays, you'd use g2d and setPaint and you'd find that you gain a lot of flexibility.

joegumbo 10-27-2008 12:56 AM

Hi jay73,

I've been Googling setPaint and g2d online on your recommendation and I see the potential. But, for now I should use the methods demonstrated in class for assignments.

Besides, my specialization is going to be networking anyhow :)

Thanks,
-Joe


All times are GMT -5. The time now is 07:02 PM.