Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-29-2007, 11:26 AM
Member
 
Join Date: Jul 2007
Posts: 6
MichYer is on a distinguished road
A loop that doesn't loop
Hi,
I need another pair of eyes to glance at the following code.I am trying to create a bar chart and this code section is supposed to draw the bars in the chart. It draws the first dataset only.
The inner loop works fine but the outer one does the first loop and then doesn't continue. Where is my error?
Thanks
Mich

Code:
if (chartType == 2) { int width = (barwidth/nSeries)/2; int jump = 0; for (int j=0;j<xTags;j++) { curx = startx+jump; for(int i=0;i<=nSeries;i++) { cury = cHeight-((barheight*seriesIdata[i][j]/yJumps)); s2d.setColor(new Color(Integer.parseInt(seriesA[i] [1]),Integer.parseInt(seriesA[i][2]),Integer.parseInt(seriesA[i][3]))); s2d.fillRect(curx,cury,width,(barheight*seriesIdata[i] [j])/yJumps); curx +=width*2; } s2d.drawString(Integer.toString(curx),30,j*10); jump += barwidth; } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-30-2007, 12:27 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Try to find out what's going on inside the outer loop:
Code:
for (int j = 0; j < xTags; j++) { System.out.printf("j = %d xTags = %d%n", j, xTags); curx = startx + jump;
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-30-2007, 10:44 AM
Member
 
Join Date: Jul 2007
Posts: 6
MichYer is on a distinguished road
Thank you
I had done so before and as I commented each line one by one and tried out various print outs I found that my problem was with the inner loop rather than the outer one.

Mich
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
do...while loop eva New To Java 16 01-31-2008 08:44 AM
while loop michcio New To Java 5 01-27-2008 02:56 AM
can you help me with this for loop? java_fun2007 New To Java 6 12-22-2007 12:20 PM
While loop leebee New To Java 1 07-18-2007 05:11 PM
Loop Help HeavyD New To Java 5 07-10-2007 03:26 PM


All times are GMT +3. The time now is 10:26 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org