Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:28:42+00:00 2026-06-02T06:28:42+00:00

I am trying to print a JTable and the print() method works great till

  • 0

I am trying to print a JTable and the print() method works great till I come to this scenario. Lets say I want to print before, in the first page only (not header) the text “Report” and on the end the text “This is the end of report”. I would like once more to clarify that I don’t need a header or footer only this text to appear in the top of the first and bottom of the last page when I print them.

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:28:44+00:00Added an answer on June 2, 2026 at 6:28 am

    One way to do this is to append() a series of suitable Printable instances to a java.awt.print.Book, as shown here.

    Addendum: JTable has a getPrintable() method that should simplify things; here’s an outline and simple title Printable:

    PrinterJob pj = PrinterJob.getPrinterJob();
    Book book = new Book();
    book.append(new Title(), pj.defaultPage());
    book.append(table.getPrintable(...), pj.defaultPage());
    book.append(new EndPage(), pj.defaultPage());
    pj.setPageable(book);
    pj.print();
    ...
    private static class Title implements Printable {
    
        Font font = new Font("SansSerif", Font.PLAIN, 48);
    
        @Override
        public int print(Graphics g, PageFormat pf, int pageIndex)
            throws PrinterException {
            Graphics2D g2d = (Graphics2D) g;
            g2d.translate(pf.getImageableX(), pf.getImageableY());
            g2d.setFont(font);
            g2d.setColor(Color.black);
            g2d.drawString("Report", 50, 200);
            return Printable.PAGE_EXISTS;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to print a JTable and I want a header and footer on
I'm trying to print out a list of products on a page. This is
I am trying to print HTML with this JavaScript in the webview, however it
I'm trying to print a Hello, AOP! message whenever Guice/AOP Alliance intercepts a method
I'm trying to print the list created by the functions in this class- what
I'm trying to print this page under the link graded fabric ArcCom in IE
I am trying to print the first tweet in the user timeline. $hometimeline =
Trying to print first 30 Ascii characters in a text box and it results
When trying to print pop I get all this weird looking formatting in F#
Im trying print Excel file data on a page. To do it i used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.