drawStripes

Thread Solved

Join Date: Sep 2006
Posts: 4
Reputation: ffire is an unknown quantity at this point 
Solved Threads: 0
ffire ffire is offline Offline
Newbie Poster

drawStripes

 
0
  #1
Nov 6th, 2006
Hey whats up im pretty new here and new to java. I have no idea when it comes to methods. (this is my first java course so im completly lost)

I have a test coming up and Im just trying to review. We got a couple examples of things that will be on the test... So we are given this complex "for loop" and we have to turn it into a few simple"ler" methods. I am having trouple doing this. the first method is supposed to draw some Stripes on an HTML file. I am having trouble "calling" or "invoking" the "drawStripes" method i created so far i have




import java.applet.*; //applet stuff
import java.awt.*; //graphics stuff
// "extends Applet" tells Java this is applet code.
public class DrawingOvals extends Applet {
// Variables to store the width and height of the desired rectangle.
int width, height;
// Standard applet method to initialize the applet.
public void init() {
width = getSize().width; //Get width info from HTML file
height = getSize().height; //Get height info from HTML file
setBackground(Color.black);
}
/******* Everything above this line IS correct******/


public void drawStripes(Graphics g, int numItemsToDraw, int stripe_width)
{

int x=0;
stripe_width = width / numItemsToDraw;
//draw a solid (filled in) rectangle
g.fillRect(x, 0, (stripe_width), height);
//add the stripe_with to x so the next stripe can start drawing where the last finished
x+=stripe_width;
}




// method in Java graphics for "painting" graphics on screen
public void paint(Graphics g) {
g.drawStripes();
}
}




any one have any clue whats wrong?
is that even on the right track?

I am trying to draw a certain number of stripes depending on what i input in the drawStripes();
for example if i want to draw 5 stripes i want to just type in 5 in the () so it looks drawStripes(5);
but idk how to do that... sorry for the real noob question guys/girls

any ideas are welcome on how to aproach this.

( its a longer thing but once i figure out how to create and call this method i should be able to do the rest on my own.)
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 4
Reputation: ffire is an unknown quantity at this point 
Solved Threads: 0
ffire ffire is offline Offline
Newbie Poster

Re: drawStripes

 
0
  #2
Nov 6th, 2006
anyone?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC