Archived

This topic is now archived and is closed to further replies.

johnnyBravo

java want to print program screen to paper

Recommended Posts

Hi i am trying to work out how to print my program screen and alls its jframes, labels etc to the printer. I know how to drawstring, line etc and print those to paper, but i dont know how to print actual objects etc. ------------ if thats not possible is this? to use getpixel function and store all those pixels into an image, then draw the image using Graphics, and then print that? ---- or is there someway to get your program to screenshot itself thanks,

Share this post


Link to post
Share on other sites
From your print(...) method, try calling the update(.) method of your main panel.


public Printer implements Printable {
Frame mainApp;
public Printer(Frame mainApp) {
this.mainApp = mainApp;
}

public print(Graphics g, PageFormat pf, int pageIndex) {
mainApp.update(g);
}
}


I don''t know if this will work, but it is worth a shot.



First make it work, then make it fast. --Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
it works it works!, thankyou so much, i thought i was going to have to create a print template instead!


i cant believe it works!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

now i some how gotta scale it down...its printing way too big

thanks again!!!!!!

Share this post


Link to post
Share on other sites