• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic