Results 1 to 6 of 6
  1. #1
    Reron08 is offline Member
    Join Date
    Oct 2008
    Posts
    1
    Rep Power
    0

    Default Drawing Bart Simpson!!

    I have an assignment in my java programming class an it involves drawing bart simpsons face. For some reason Jcreator and Bluej won't let me assign a color to fill in my shapes. And i am having difficulty drawing his mouth as well. If anyone could help that would be great.

    Here's the Code:

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

    //import javax.swing.JFrame;
    //import javax.swing.JPanel;

    public class BartSimpson extends Applet { //JPanel {

    public void init(){
    }

    public void paint(Graphics g) {
    int xpoints[] = {5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 105, 5};
    int ypoints[] = {5, 10, 15, 10, 5, 10, 5, 10, 5, 10, 5, 100, 100};
    int npoints = 13;

    //Color mediumBlue = new Color(128, 128, 255);
    //public final static Color yellow = new Color(255, 255, 0);
    //public final static Color YELLOW = yellow;

    //Bart's Head
    g.setColor(Color.yellow);
    g.drawPolygon(xpoints, ypoints, npoints);
    g.fillPolygon(xpoints, ypoints, npoints);

    //Bart's Right Eye
    g.setColor(Color.white);
    g.fillOval(75, 60, 30, 30);
    g.setColor(Color.black);
    g.fillOval(75, 60, 30, 30);

    //Bart's Nose
    g.setColor(Color.yellow);
    g.fillRoundRect(75, 85, 35, 15, 15, 15);

    //Bart's Left Eye
    g.setColor(Color.white);
    g.fillOval(50, 60, 30, 30);
    g.setColor(Golor,black);
    g.fillOval(50, 60, 30, 30);

    }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default

    won't let me assign a color to fill in my shapes.
    Do you get error messages? Please post them here.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Missing import?

    db

  4. #4
    JDCAce's Avatar
    JDCAce is offline Member
    Join Date
    Oct 2008
    Location
    Columbus, GA, US
    Posts
    29
    Rep Power
    0

    Default

    Java Code:
    //Bart's Left Eye
    g.setColor(Color.white);
    g.fillOval(50, 60, 30, 30);
    [b][i]g.setColor(Golor,black);[/i][/b]
    g.fillOval(50, 60, 30, 30);
    I'm not sure if you copy-and-pasted or not, but if you did, there's your problem. "Golor,black" is a typo; change it to "Color.black" (without the quotes).
    "Things are made of littler things that jiggle."

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default

    Nice catch.
    OPs need to learn to post the error messages.
    Some of us are too lazy to scan that closely for the typos.

  6. #6
    Unome is offline Member
    Join Date
    Oct 2008
    Posts
    44
    Rep Power
    0

    Default

    Wow. Bart Simpson drawing for Programming? My stupid class didn't require anything but drawing a house... I learned a little more than that though.

    As for your question.. crap it was answered. I hate it when I mess spelling up by one letter. It happens to me all the time

Similar Threads

  1. Using Piccolo for Drawing
    By rstepler in forum Java 2D
    Replies: 2
    Last Post: 08-20-2013, 10:03 AM
  2. Problem with 3D drawing.
    By Supamagier in forum Advanced Java
    Replies: 0
    Last Post: 08-31-2008, 12:39 PM
  3. Demonstration of drawing an Arc in SWT
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 06-28-2008, 09:24 PM
  4. Help with 2-D Drawing
    By Deathmonger in forum New To Java
    Replies: 4
    Last Post: 06-18-2008, 02:23 AM
  5. Help with Drawing a line
    By Rgfirefly24 in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:40 AM

Posting Permissions

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