Sign in to follow this  

[java] Resizing window?

This topic is 4305 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

Guest Anonymous Poster
yes I am drawing something on my window and when I make the window bigger the stuff that I drew doesn't scale up to the new window size.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
yes I am drawing something on my window and when I make the window bigger the stuff that I drew doesn't scale up to the new window size.

Share this post


Link to post
Share on other sites
What layout are you setting on the frame? If you're setting any layout (such as say, FlowLayout), then the panel within the frame won't size to the bounds of the frame. What you want to do is not set any layout at all on the frame (just leave it with its default) and you should get the desired result.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
wow!!!! that worked and was super easy. Thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Now, I have one more problem. I have a button on my window for print. How do you print to the printer your screen or your window?

Share this post


Link to post
Share on other sites
1. Implement the java.awt.print.Printable interface
2. Invoke java.awt.print.PrinterJob.getPrinterJob() to get an instance of a printer job.
3. java.awt.print.PrinterJob.setPrintable(...) passing in your Printable object.
4. java.awt.print.PrinterJob.printDialog()

It's been a while since I have done it, but that is close. You can look at all the stuff under java.awt.print.* package to see how it works.

Share this post


Link to post
Share on other sites
Quote:
Original post by CaptainJester
1. Implement the java.awt.print.Printable interface
2. Invoke java.awt.print.PrinterJob.getPrinterJob() to get an instance of a printer job.
3. java.awt.print.PrinterJob.setPrintable(...) passing in your Printable object.
4. java.awt.print.PrinterJob.printDialog()

It's been a while since I have done it, but that is close. You can look at all the stuff under java.awt.print.* package to see how it works.


hehe, if only it were that easy.

There are some tutorials on printing on the Java website. I suggest you look those up. While going through them, they don't mention the fact that you should be prepared to print any page of your document at any time, even if you don't anticipate the need to print pages out-of-order. The printing API ends up actually calling the print method TWICE for the first page. This caused a problem for me when I first used it as I was consuming my text as I was printing it. I was rather confused when page 1 would never come out.

Share this post


Link to post
Share on other sites
Quote:
Original post by capn_midnight
hehe, if only it were that easy.

There are some tutorials on printing on the Java website. I suggest you look those up. While going through them, they don't mention the fact that you should be prepared to print any page of your document at any time, even if you don't anticipate the need to print pages out-of-order. The printing API ends up actually calling the print method TWICE for the first page. This caused a problem for me when I first used it as I was consuming my text as I was printing it. I was rather confused when page 1 would never come out.


I have only printed images, so it was that easy for me. I always checked what page I needed to print and printed accrodingly.

Share this post


Link to post
Share on other sites

This topic is 4305 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this