printing problem very urgent


i have the following code to print:

private void Print() {
        Frame f = new Frame( "Printing" );
        PrintJob pj = f.getToolkit().getPrintJob( f, "Printing Results", null );
        if ( pj != null ) {
            g = pj.getGraphics();
            fnt = new Font( "Trebuchet MS", Font.PLAIN, 14 );
            g.drawString(textareaEng.getText() + "\n\n" + textareaFre.getText() + "\n\n" + textareaSol.getText(), 30, 30 );

but the problem is when its printed, i get small squares where there should be a new line!

if i was to use JDK1.5 which im currently using for writing program everything works perfect cos i use replaceAll(), but my client is running JDK1.3 and replaceAll only works for JDK1.4 and higher. (to my knowledge)

i need to be able to overcome this and print newlines where "\n" is instead of squares...

so say

textareaEng = "hello world";
textareafre = "bonjour monde";
textareaSol = "sosol lf";

using my code above would print

hello world □□ bonjour monde □□ sosol lf

but i want it to print out so it looks like :

hello world

bonjour monde

sosol lf

this is very urgent

thanks sean
LVL 16
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ellandrdAuthor Commented:
sorry i used the character map to show small squares but □□ showed up instead  - sorry

hope you stillunderstand by what i mean from above?!
zzynxSoftware engineerCommented:

            g.drawString(textareaEng.getText() + "\n\r\n\r" + textareaFre.getText() + "\n\r\n\r" + textareaSol.getText(), 30, 30 );


(or  "\r\n\r\n")
ellandrdAuthor Commented:
i tried \r\n and it didnt work but will try \n\r so please wait a minute till i update my code...
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

ellandrdAuthor Commented:
nope it didnt work!
zzynxSoftware engineerCommented:
Eventually you can split

            g.drawString(textareaEng.getText() + "\n\n" + textareaFre.getText() + "\n\n" + textareaSol.getText(), 30, 30 );


int y = 30;
g.drawString(textareaEng.getText(), 30, y);
y+=40; // 40 or another number
g.drawString(textareaFre.getText(), 30, y);
g.drawString(textareaSol.getText(), 30, y);

can't you?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ellandrdAuthor Commented:
jeez never tried that!

havent got my java head on....

will be right back
zzynxSoftware engineerCommented:
Should work I think
ellandrdAuthor Commented:
yes it worked!

thank you for the fast reply adn working answer!

500 points and grade A

cheers sean
zzynxSoftware engineerCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.