3 Replies - 383 Views - Last Post: 18 March 2009 - 08:07 PM Rate Topic: -----

#1 eggie9001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-February 09

Loop Help

Posted 18 March 2009 - 06:22 PM

// Lab05a


import java.awt.*;
import java.applet.*;


public class Lab05a extends Applet
{
	public void paint(Graphics g)
	{
		int height = 640;
		int width = 990;
		int xoffset = 10;
		int yoffset = 640;

		
		
		g.drawRect(10, 10, 980, 630);
		
		// Draw bottom-right corner
		for (int x=0; x<=97; x++)
		{
			g.drawLine(xoffset, yoffset, width, height);
			xoffset += 10;
			height -= 6;
		}

		
		// Draw bottom-left corner


		// Draw top-right corner
	
	
		// Draw top-left corner
	
	}
}




What I was trying to do was make another one of these:
http://i186.photobuc...01/JavaLoop.jpg
But only make it on the bottom left corner of the screen. I tried switching the xoffset +=10 to xoffset -=10 and so on with that and also the height -=6. Could someone help?

Also, the loop structures are being drawn in a rectangle (it was in the lab instructions) not in the full applet window.

Thanks,
Joe

This post has been edited by eggie9001: 18 March 2009 - 08:09 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Loop Help

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Loop Help

Posted 18 March 2009 - 07:08 PM

g.drawLine(xoffset, yoffset, width, height);

g.drawLine(x1, y1, x2, y2) from x1,y1 to x2,y2

nothing to do with width and height
Was This Post Helpful? 0
  • +
  • -

#3 eggie9001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-February 09

Re: Loop Help

Posted 18 March 2009 - 07:52 PM

I don't exactly get what you're trying to say, but I'll work with it and let you know what happens.
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Loop Help

Posted 18 March 2009 - 08:07 PM

View Posteggie9001, on 18 Mar, 2009 - 06:52 PM, said:

I don't exactly get what you're trying to say, but I'll work with it and let you know what happens.

And "Java Code Help" as topic title is kind a useless in a forum dedicated to help programmers with Java
Go back to Edit your first topic, Edit it "full edit" and change your topic title
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1