Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

PageSetup and Printing of JTextArea contents

843807Jun 28 2010 — edited Jul 9 2010
Dear All,

I am implementing a small text editor program, using
JTextArea
. The program has PageSetup and Print menu items.

The PageSetup menu item handler is given below and is working. Meaning if I do a PageSetup and change the page options like Landscape to portrait etc, the changes are checked to be retained when I enter PageSetup again, as pageFormat retains them.
// instance variable
PageFormat pageFormat = printerJob.defaultPage();

// handler code
void filePageSetupHandler( ActionEvent ae ) {
	pageFormat=printerJob.pageDialog(pageFormat);
}
However, how do I use the pageFormat obtained in the above handler to implement the Print handler? I have tried various things, but no suceess. Here is the partially completed Print handler code.
void filePrintHandler( ActionEvent ae ) {
	// how do I use the pageFormat information obtained earlier, in this place???
	textArea.print(null,null,true,null,null,true);
}
Any help will be greatly appreciated.

Regards,
Sudheendran T L

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 6 2010
Added on Jun 28 2010
5 comments
7,850 views