Does "\n" (carriage return) works with g.drawString() method? I have tried and found , its not working ? Lets say if I have to draw a string on the applet in a loop line after line , how will I ? Can somebody Tell me. I tried this line in a loop which is not working : g.drawString("Something\n",100,100); thanx in advance. Regards,
It doesn't work because the drawString method is not text based (like a terminal or word processor). It simply duplicates the fonts using pixel, etc. in the Graphics object. The only way to get a new line is to write out the next line using another drawString call and a new 'y' coordinate. Sometimes you'll see stuff like this.
Sam, The answer given by Sean is very good. I hope it helped you solve your problem. Next time, please be sure to register with a proper name. "Sam" does not follow the conventions. See here for details: http://www.javaranch.com/name.jsp If you do not register properly, your account will be disabled. I would hate to see that happen. Thank you. Stephanie
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!