Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't draw a string even the Graphics object isn't null!

 
Howard Ting
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have an applet that need to read a large image (9200x9200). For not haging the users around, unable to do anything but wait, I use a class extending Thread to load the image so that the users can quit the applet as they want.
My problem is I can't draw a string showing the loading procedure. I'm doing it this way: Getting the Graphics object in the loading class and drawing the loaded data ratio, but it's not working. Here's a part of my code:



"g is not null." is printed during loading, so this is not a question about getGraphics(), but I still get nothing shown on the screen.
What's the problem with it? If this is not a right way, why not?

Any reply is appreciated~
 
jay kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why dont u use println to print the value u r using in drawString(),
, might be that the value itself is null, and dont forget to check for exceptions !!!
 
Howard Ting
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, jack, you're right. Now I'm printing any messenge in the console window. It's convenient, yet it only works with the appletviewer...
I found the solution to this problem somehow, which is putting the getGraphics() maethod in the reading loop. I don't know why, so I'll appreciate if someone can explain it for me.
 
Vlado Zajac
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand your solution. I would put the painting code in overriden paint method or use Label or JLabel for displaying text.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic