how craete the applet to draw a house with two windows and one door and its roof

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lubona
    New Member
    • Oct 2013
    • 3

    how craete the applet to draw a house with two windows and one door and its roof

    I need a help on how can I draw applet that look like how with two windows and one doors
    Attached Files
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    You should start with this tutorial and then try yourself. If you have specific problems with understanding something or with code, give us more details.

    Comment

    • Lubona
      New Member
      • Oct 2013
      • 3

      #3
      thankx Nepok but my problem is how can draw a door and windows can you check this code may be may you can help me
      Code:
      import java.applet.Applet;
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.awt.Graphics;
      public class NewClass extends Applet{
            @Override
          public void paint(Graphics g){
      int hor[]={40,20,40,70,40,40,70,70,90,70};
      int vert[]={20,40,40,40,40,60,60,40,40,20};
      int pts=hor.length;
      g.drawPolygon(hor,vert,pts);
      Last edited by Rabbit; Nov 7 '13, 06:39 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        The code you posted looks incomplete, so I can't see all of what you're doing. Also, please post code in [CODE]...[/CODE] tags - they make code much easier to read.

        Now, generally speaking you can use all of the drawing functions from the Graphics class. That includes rectangles, lines, polygons and ovals (just to name a few). And you're not limited to just using one - you could for example do something like this:
        [code=java]//...
        g.drawRect(20, 40, 20, 20);
        g.drawLine(20, 30, 40, 30);
        g.drawLine(30, 40, 30, 20);
        //...[/code] That should be a window.

        Comment

        Working...