Link to home
Start Free TrialLog in
Avatar of ellandrd
ellandrdFlag for Ireland

asked on

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
Avatar of ellandrd
ellandrd
Flag of Ireland image

ASKER

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

hope you stillunderstand by what i mean from above?!
Avatar of zzynx
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")
i tried \r\n and it didnt work but will try \n\r so please wait a minute till i update my code...
nope it didnt work!
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jeez never tried that!

havent got my java head on....

will be right back
Should work I think
yes it worked!

thank you for the fast reply adn working answer!

500 points and grade A

cheers sean
:°))