Printing from a text pane  
Author Message
yorkmac





PostPosted: 2005-3-24 10:19:00 Top

java-programmer, Printing from a text pane i am making a small RTF word processor and trying to print from a
JTextPane.The setPrintable method is giving me problems as i dont know
what to pass to it


protected void printData()
{
getJMenuBar().repaint();
try
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable();

if(!printJob.printDialog())
return;
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR ) );
printJob.print();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR ) );

}
catch(PrinterException e)
{
e.printStackTrace();
System.err.println("Printing error" + e.toString() );
}
}



 
Hiroshi Iwatani





PostPosted: 2005-3-24 18:12:00 Top

java-programmer >> Printing from a text pane yorkmac wrote:

>i am making a small RTF word processor and trying to print from a
>JTextPane.The setPrintable method is giving me problems as i dont know
>what to pass to it
>
>
> protected void printData()
>{
> getJMenuBar().repaint();
> try
> {
> PrinterJob printJob = PrinterJob.getPrinterJob();
> printJob.setPrintable();
>
> if(!printJob.printDialog())
> return;
> setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR ) );
> printJob.print();
> setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR ) );
>
> }
> catch(PrinterException e)
> {
> e.printStackTrace();
> System.err.println("Printing error" + e.toString() );
> }
>}
>
>
>
>
>
http://java.sun.com/j2se/1.5.0/docs/guide/jps/index.html
This documentation has basic example codes.