Strange behavior from a Java Graphics drawString call in a loop

I'm at a complete loss here. I have a method that goes through a Vector of TreePaths containing a custom FileNode class, and extracts the File contained in each last node. The result is a printed list of all the filenames in the Vector. I had a for loop to increment through it, and it worked fine, but I changed it to a while loop to allow me to have multiple pages. Now, for some reason, it only prints the last 11 files. I've figured out what's causing it, but I don't know why or how to fix it. I added in lines to print to the console 'lineCount' and 'printPaths.size()', and discovered that lineCount was incrementing until it hit 55, then reverting to 15 and continuing to increment. The names did not actually start printing until it reverted to 15. I've stepped through it in debug mode, and it goes through the print loop 55 times, returns the code to the print function that tells it it's part of the printed page, then it drops into a print method for which I don't have the source, and when I step back up out of that, it is back at the beginning of the loop, and lineCount is at 14. The really odd part is that's when it prints out the 11 files, even though according to the program it hasn't even looked at that part of the Vector yet. If anyone has the slightest idea what's causing that, I would really appreciate the help. Here's the chunk of code that deals with printing the list. Hopefully that's enough. lineCount = 13; int lineSpacing = 14; g.setFont(new Font("Dialog", Font.PLAIN, 10)); boolean color = true; if (summ) { g.drawString(((TreePath) printPaths.get(0)).getPathComponent( ((TreePath) printPaths.get(0)).getPathCount() - 3) .toString() + " : " + ((TreePath) printPaths.get(0)).getPathComponent( ((TreePath) printPaths.get(0)).getPathCount() - 5) .toString(), 36, lineCount * lineSpacing); lineCount++; //for (int j = 1; j < printPaths.size(); j++) { while((printPaths.size()>1) && lineCount

以上就是Strange behavior from a Java Graphics drawString call in a loop的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏