Posted on 2003-03-05
I asked the following question before but stuck on implementation of the answer. i wouod appriciate if anyone could specifically tell me how to do it or provide me some fragment of codes.
When I draw a string with the drawString method of the Graphics class, it ignores escape characters such as \n.
For example if I execute the following code:
str="TESTING TEXT: newline:\n tab:\t END";
g.drawString(str, pvalx, pvaly+ascent);
System.out.println cmmand prints out the string in a correct format on the command prompt screen, like
TESTING TEXT: newline:
but drawString ignores the escape characters and prints out text in a single line like
Can anyone please tell me how to overcome this problem so that the string can be drawn in the correct format?
Yes, you should break your text into separate strings and
put them in place one by one.
It's easy to write code that puts every next line so-many pixels lower.