Results 1 to 5 of 5
Thread: Snowman Applet
- 01-14-2013, 01:52 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 44
- Rep Power
- 0
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 01:56 AM.
- 01-14-2013, 04:19 AM #2
Re: Snowman Applet
Have you read the API for Graphics?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-14-2013, 04:27 PM #3
Member
- Join Date
- Nov 2012
- Posts
- 44
- Rep Power
- 0
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?
- 01-15-2013, 03:55 PM #4
Member
- Join Date
- Nov 2012
- Posts
- 44
- Rep Power
- 0
Re: Snowman Applet
Im assuming so.....????
- 01-15-2013, 04:23 PM #5
Member
- Join Date
- Nov 2012
- Posts
- 44
- Rep Power
- 0
Similar Threads
-
Java Applet starts then the applet field goes light blue
By oki in forum Java AppletsReplies: 30Last Post: 08-26-2011, 09:05 PM -
Snowman Applet - SWING
By Angry@Java in forum New To JavaReplies: 1Last Post: 05-05-2011, 02:19 AM -
Moving snowman
By Star in forum AWT / SwingReplies: 0Last Post: 04-09-2011, 08:27 PM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks