Welcome to Dream.In.Code
Become a Java Expert!

Join 150,372 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,784 people online right now. Registration is fast and FREE... Join Now!




Creating a the sideview of stair steps from the lower left to the uppe

 
Reply to this topicStart new topic

Creating a the sideview of stair steps from the lower left to the uppe

pmoney30
14 Feb, 2008 - 05:28 PM
Post #1

New D.I.C Head
*

Joined: 6 Feb, 2008
Posts: 8

CODE

import javax.swing.JApplet;


import java.awt.*;
import java.applet.*;
public class Stair extends JApplet {

    /**
     * Initialization method that will be called after the applet is loaded
     * into the browser.
     */
    public void init() {
        // TODO start asynchronous download of heavy resources
    }
public void paint(Graphics page) {
      
        for ( int x = 10; x <= 350; x+=10)
        {
            for ( int y = 200; y <= -350; y-= 190)
            {
                
                page.drawLine( x,y,x,y-190);
                page.drawLine(x, y, x+50, y);
            }
        }
            }
        }


This is my code to draw the staircase, but noting is appearing on the applet screen.
Help Appreciated.


User is offlineProfile CardPM
+Quote Post

Ellie
RE: Creating A The Sideview Of Stair Steps From The Lower Left To The Uppe
15 Feb, 2008 - 02:48 AM
Post #2

D.I.C Regular
Group Icon

Joined: 17 Jan, 2007
Posts: 429



Thanked: 4 times
Dream Kudos: 150
My Contributions
Hi,

You have a loop problem, your y condition says:

for ( int y = 200; y <= -350; y-= 190)

Well, y will never be less than -350, so you just need to change it to:

for ( int y = 200; y >= -350; y-= 190)

icon_up.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:33PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month