aspose file tools*
The moose likes Java in General and the fly likes I'm trying to develope an applet that... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "I Watch "I New topic
Author

I'm trying to develope an applet that...

Michael Ossino
Greenhorn

Joined: Dec 16, 2003
Posts: 9
I'm trying to develope an applet that will use the graphics and Java2D operators to draw a simple winter scene with a house and a snowman. The house will be pretty simple a square house with a rectangle door, 2 square windows, a triangle for the roof, and a rectangle chimney, with 3 puffs of smoke comming out of it that are gradually bigger. Also there will be a quarter cirlce of the sun poking out of the left top of the sceen, and a cloud consisting of a few cirlces. There will also be a blue sky and white for the snowy ground.
The snowman will be 3 circles with 2 stick arms 2 buttons and a face consisting of 2 black circles for the eyes and an arc for the smile. Also the snowman will be positioned on a blue square.
Each of these will have there own methods.
So far this is all I have:
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.*;
import javax.swing.*;
public class SnowmanApplet extends JApplet
{
public void paint( Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
setBackground(Color.cyan);
House house1 = new house(5,20);
Snowman snowman1 = new snowman(100,100);
house1.drawhouseouse(g2);
snowman1.drawSnowman(g2);
}
}

I doubt I have the coordinates correct though. I'm kind of rusty on my Java, could someone please give me some suggestions on how to go about the other parts? Thanks in advance
Michael Ossino
Greenhorn

Joined: Dec 16, 2003
Posts: 9
Ok i got this so far, but now I'm having trouble compiling it. it won't let me compile over the Arc2D method. What am I doing wrong with it? It works fine with everything else. Also The coordinetes aren't right on the arc I plan on tweeking it after I figure out why it won't compile.
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;
public class Winter extends JFrame {
public Winter()
{
super ("Winter Scene");
getContentPane().setBackground(Color.CYAN);
setSize(500,500);
setVisible(true);
}
public void paint(Graphics g)
{
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(Color.YELLOW);
g2d.fill (new Rectangle2D.Double(50, 200, 200, 200));
g2d.setPaint(Color.BLUE);
g2d.fill (new Rectangle2D.Double(65, 220, 50, 50));
g2d.setPaint(Color.BLUE);
g2d.fill (new Rectangle2D.Double(185, 220, 50, 50));
g2d.setPaint(Color.RED);
g2d.fill (new Rectangle2D.Double(125, 300, 50, 100));
g2d.setPaint(Color.BLUE);
g2d.fill (new Rectangle2D.Double(326, 390, 99, 40));
g2d.setPaint(Color.WHITE);
g2d.fill (new Ellipse2D.Double(325, 320, 100, 100));
g2d.setPaint(Color.WHITE);
g2d.fill (new Ellipse2D.Double(337, 260, 75, 75));
g2d.setPaint(Color.WHITE);
g2d.fill (new Ellipse2D.Double(348, 220, 50, 50));
g2d.setPaint(Color.BLACK);
g2d.fill (new Ellipse2D.Double(355, 230, 10, 10));
g2d.setPaint(Color.BLACK);
g2d.fill (new Ellipse2D.Double(378, 230, 10, 10));
g2d.setPaint(Color.BLACK);
//g2d.setStroke( new BasicStroke(1.Of));
g2d.draw (new Arc2D.Double(365,250, 40, 40, 265, 275));
}
public static void main (String args[])
{
Winter application = new Winter();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
The reason your programme doesn't compile at the moment is that you are missing a parameter from Arc2D.Double's intialization. You have six arguments and the constructor is expecting 7. I believe you are missing the type argument from the end of the list.
Hope this get you back on track,
Nigel Brown
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I'm trying to develope an applet that...