?
Solved

String problem

Posted on 2003-02-25
1
Medium Priority
?
175 Views
Last Modified: 2010-03-31
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(str);

System.out.println cmmand prints out the string in a correct format on the command prompt screen, like

TESTING TEXT: newline:
 tab:    END


but drawString ignores the escape characters and prints out text in a single line like

TESTING TEXT:newline:tab:END


Can anyone please tell me how to overcome this problem so that the string can be drawn  in the correct format?

Thanx
0
Comment
Question by:asukai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 24

Accepted Solution

by:
sciuriware earned 200 total points
ID: 8015894
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.
If you don't like that you should use a (SWING) control that interpretes HTML, but then you should change your string data accordingly.
;JOOP!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question