Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How to draw a houses using Java Applets and Awt?

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to draw a houses using Java Applets and Awt?

    i need a code to draw three houses using different methods in java, can someone help me?

    i have this code to draw using the appleteviewer:
    import java.awt.*;
    import java.applet.Applet;
    public class House extends Applet{
    public void paint(Graphics g){

    g.drawLine(100, 10, 80, 20);
    g.drawLine(80, 20, 120, 20);
    g.drawLine(120, 20, 100, 10);
    g.drawLine(90, 20, 90, 50);
    g.drawLine(110, 20, 110,50);
    g.drawLine(90, 50, 110, 50);
    }
    }


    but i need to use different method, help me!
    Last edited by Deep_4; November 7th, 2012 at 10:30 PM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Drawing a house using methods

    What have you tried? Where are you stuck?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    58
    My Mood
    Sleepy
    Thanks
    2
    Thanked 3 Times in 2 Posts

    Wink Re: Drawing a house using methods

    Hi,

    This example uses your program and adds buffering as well as separating the data of drawing the house. Look at the drawHouse method: this allows you to move the house on the X and Y axis. This should give you a start; you should be able to draw several houses in a loop or something like that? Have a mess about with the code and see what you can make happen :-)
    /**code removed by moderator*/
    Have fun,

    Shaun.
    Last edited by jps; October 31st, 2012 at 01:14 AM. Reason: removed code

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Drawing a house using methods

    @ShaunB
    Please read the problem with spoonfeeding.

  5. #5
    Member
    Join Date
    Dec 2009
    Location
    UK
    Posts
    58
    My Mood
    Sleepy
    Thanks
    2
    Thanked 3 Times in 2 Posts

    Default Re: Drawing a house using methods

    Quote Originally Posted by jps View Post
    @ShaunB
    Please read the problem with spoonfeeding.
    Okay, thanks. But I didn't think that my solution was that good to be honest. You could probably have done it better.

    Regards,

    Shaun.

Similar Threads

  1. Why and where abstract methods & classes and static methods are used?
    By ajaysharma in forum Object Oriented Programming
    Replies: 7
    Last Post: July 14th, 2012, 01:16 AM
  2. drawing is in the same postion :(
    By kisokiso in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 20th, 2011, 08:02 AM
  3. Drawing a pentagon
    By Zomosa in forum AWT / Java Swing
    Replies: 7
    Last Post: October 11th, 2011, 10:21 PM
  4. [SOLVED] Drawing on JFrame
    By kbarrett1989 in forum AWT / Java Swing
    Replies: 3
    Last Post: October 31st, 2010, 03:41 AM
  5. Drawing
    By toxikbuni in forum Java Theory & Questions
    Replies: 0
    Last Post: April 20th, 2010, 02:43 PM