Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

java - How to print a jtable with a image in the header?

i want to print something like this

IMAGE

TITLE

JTABLE

i know to print a jtable with the title in a messageFormat header but i dont know how to add the image

The image is a logo

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You might try the approach shown here. Use drawImage() instead of drawString() in your Image printable.

private static class Image implements Printable {…}
private static class Title implements Printable {…}

PrinterJob pj = PrinterJob.getPrinterJob();
Book book = new Book();
book.append(new Image(), pj.defaultPage());
book.append(new Title(), pj.defaultPage());
book.append(table.getPrintable(...), pj.defaultPage());
book.append(new EndPage(), pj.defaultPage());
pj.setPageable(book);
pj.print();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...