printing problem very urgent

hi,

i have the following code to print:

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

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
ellandrdAsked:
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?!
0
zzynxSoftware engineerCommented:
Does

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

help?

(or  "\r\n\r\n")
0
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...
0
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!
0
zzynxSoftware engineerCommented:
Eventually you can split

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

into

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


can't you?
0

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
0
zzynxSoftware engineerCommented:
Should work I think
0
ellandrdAuthor Commented:
yes it worked!

thank you for the fast reply adn working answer!

500 points and grade A

cheers sean
0
zzynxSoftware engineerCommented:
:°))
0
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
Java

From novice to tech pro — start learning today.