Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Printing using the Printer (http://www.programmingforums.org/showthread.php?t=11521)

Xian_Fung Oct 8th, 2006 3:52 PM

Printing using the Printer
 
The program I'm working on reads info from a MYSQL database and displays it onto a JTextArea. I need to print what is displayed, but in the API, it seems to profer printing from files. Writing to a file then printing from it is a little wierd, what can I do?

andro Oct 8th, 2006 8:24 PM

One way to go about it would be to create a class that extends JTextArea and implements Printable.

Then you could just add a print() method, that calls printJob.setPrintable(this) along the way.


In the 1.6 JDK, all classes that inherit from JTextComponent have support for printing by default, so you won't have to do this anymore.

Xian_Fung Oct 10th, 2006 7:28 PM

Ah, thank you very much. I will try it out as soon as I fix a couple critical errors...


All times are GMT -5. The time now is 1:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC