printing JEditorPane

M

marcind

hello
at the begining I wont to apologies everyone because i knew that this
subject was on the group many times but nowhere I could find working example
of solving this problem;
if anyones could help me with printing contents of JEditorPane that containt
html formatted text i would be gratefully.

I manage to print graphic (using drawLine()) but how print JeditorPane ??

thanks for any suggestions.

example printing line :


public class Print2 extends JEditorPane implements Printable
{

public static void main(String[] args) {
Print2 pp= new Print2();
pp.imprimir();
}

public Print2() {
super();
}

public void imprimir()
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

public void paintComponent(Graphics g)
{
System.out.println("paintComponent "+g);
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g = (Graphics2D) getComponentGraphics(g2);
g.drawLine(0,0,100,100);
}

public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
{
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
g = (Graphics2D) getComponentGraphics(g);
g.drawLine(0,0,400,100);
return Printable.PAGE_EXISTS;
}
}
 
S

Symon

If you use the latest JRE (1.5), there is a print() method on every
Components. Pretty usefull... :)
 
M

marcind

U¿ytkownik "Symon said:
If you use the latest JRE (1.5), there is a print() method on every
Components. Pretty usefull... :)
unfortunatly I have to use JRE 1.42; does anywhone manage to print JEditPane
somahow ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top