Need Help with java project {Please...}
Results 1 to 5 of 5

Thread: Need Help with java project {Please...}

  1. #1
    Junior Member
    Join Date
    Oct 2002
    Posts
    22

    Need Help with java project {Please...}

    HI,


    I working on this java project where I have to construct an applet. The applet has to be an Ellipse thats is filled with a color other than white and it has to resize when the window is minimized. Here is what I have so far... If there is anyone who can help me with this problem I would gladly appreciate it as this project is due tomorrow..Thnx in advance.


    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;

    public class EllipseApplet extends Applet
    {
    public void paint (Graphics g)
    { // recover Graphics2D
    Graphics2D g2 = (Graphics2D)g;

    //Construct an Ellipse and draw it.
    Ellipse2D.Double easterEgg = new Ellipse2D.Double(5, 10, 20, 30);
    g2.setColor(Color.blue);
    g2.fill(easterEgg); // fill the ellipse in blue

    }
    }


    However I keep getting an error when I compile the program and I don't quite understand it.
    This is the error message;

    H:\EllipseApplet.java:13: cannot resolve symbol
    symbol : variable Color
    location: class EllipseApplet
    g2.setColor(Color.blue);
    ^
    1 error

    Tool completed with exit code 1
    The strong do as they will and the weak suffer what they must.It is a choice. You don\'t choose to do the right thing all the time. You do the right thing all the time. Wining is a habit, unfortunately so is losing.

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255

    Re: Need Help with java project {Please...}

    Originally posted here by Big_Bolo
    H:\EllipseApplet.java:13: cannot resolve symbol
    symbol : variable Color
    location: class EllipseApplet
    g2.setColor(Color.blue);
    ^
    It's pretty straightforward, it's complaining about your use of Color.blue, primarily because java.awt.Color isn't imported at the top of your file. If you add the import it will probably work fine.
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  3. #3
    Junior Member
    Join Date
    Oct 2002
    Posts
    22
    Thnx Chsh

    I didn't even know I had to import java.awt.Color. I thought about it but I didn't write because it wasn't mentioned in the java book I'm reading. I'm new with programming in java. Thnx I really appreciate your help.
    The strong do as they will and the weak suffer what they must.It is a choice. You don\'t choose to do the right thing all the time. You do the right thing all the time. Wining is a habit, unfortunately so is losing.

  4. #4
    Senior Member
    Join Date
    Oct 2001
    Posts
    872
    easy way out:

    import java.awt.*;
    import java.applet.*;

    etc. etc.
    ...This Space For Rent.

    -[WebCarnage]

  5. #5
    Junior Member
    Join Date
    Oct 2002
    Posts
    22
    ok.

    I fixed the error and the program is running fine. Now I'm trying to figure out how to use the getWidth() and getHeight() methods to centre my ellipse in the applet and have it resize itself when I resize the window. If u can help with this two methods by looking at the code I would really appreciate. I very new at programming, there is still a lot of stuff that I don't know.
    Thnx in advance.
    The strong do as they will and the weak suffer what they must.It is a choice. You don\'t choose to do the right thing all the time. You do the right thing all the time. Wining is a habit, unfortunately so is losing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides