Jump to content
  • Advertisement

Archived

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

johnnyBravo

java want to print program screen to paper

This topic is 5279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!