Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Snowman Applet

  1. #1
    hockey101 is offline Member
    Join Date
    Dec 2012
    Posts
    44
    Rep Power
    0

    Default Snowman Applet

    Alright, I'm having trouble on putting text in my applet. It says I need to put my name in the upper-left corner. I have managed to get a frowny face, shift it 20 pixels to the right, put 2 red buttons in the upper torso, and I also got the sun in the upper right corner. Now how do I get my name in the upper left corner? Any advice?

    Here is my code...

    Java Code:
    package applet;
    
    import java.applet.Applet;
    import java.awt.*;
    
    
    public class Snowman extends Applet
    {   
       
        public void paint (Graphics page)
        {
           final int MID = 150;
           final int TOP = 50;
    
    
           setBackground (Color.cyan);
    
    
           page.setColor (Color.blue);
           page.fillRect (0, 175, 300, 50);  //ground
    
           page.setColor (Color.yellow);
           page.fillOval(300, -40, 80, 80);  //sun
    
           page.setColor (Color.white);
           page.fillOval (MID-0, TOP, 40, 40);
           page.fillOval (MID-15, TOP+35, 70, 50);
           page.fillOval(MID-30, TOP+80, 100, 60);
    
           page.setColor (Color.red);
           page.fillOval (MID+14, TOP+42, 10, 10);
           page.fillOval (MID+14, TOP+60, 10, 10);
           
           page.setColor (Color.black);
           page.fillOval (MID+10, TOP+10, 5, 5);
           page.fillOval (MID+25, TOP+10, 5, 5);
    
           
    
           page.drawArc (MID+10, TOP+25, 20, 10, 10, 160);
    
           
           
           page.drawLine (MID-5, TOP+60, MID-30, TOP+40);
           page.drawLine (MID+45, TOP+60, MID+75, TOP+60 );
    
           page.drawLine (MID+0, TOP+5, MID+40, TOP+5);
           page.fillRect (MID+5, TOP-20, 30, 25);
        }
    }
    Last edited by hockey101; 01-14-2013 at 02:56 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: Snowman Applet

    Have you read the API for Graphics?

    db
    hockey101 likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    hockey101 is offline Member
    Join Date
    Dec 2012
    Posts
    44
    Rep Power
    0

    Default Re: Snowman Applet

    I see that I have to use drawChars, but where do I put that? It says I need to make a public void statement, so do I put that in my main class?

  4. #4
    hockey101 is offline Member
    Join Date
    Dec 2012
    Posts
    44
    Rep Power
    0

    Default Re: Snowman Applet

    Im assuming so.....????

  5. #5
    hockey101 is offline Member
    Join Date
    Dec 2012
    Posts
    44
    Rep Power
    0

Similar Threads

  1. Replies: 30
    Last Post: 08-26-2011, 10:05 PM
  2. Snowman Applet - SWING
    By Angry@Java in forum New To Java
    Replies: 1
    Last Post: 05-05-2011, 03:19 AM
  3. Moving snowman
    By Star in forum AWT / Swing
    Replies: 0
    Last Post: 04-09-2011, 09:27 PM
  4. Replies: 4
    Last Post: 06-08-2007, 07:15 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
  •