0

When I print out the information on the jTable, it only prints about two and a half Columns of the seven column jTable.

Here is a copy of the code that prints the table:

public class printprogram implements Printable, ActionListener {

    public int print(Graphics g, PageFormat pf, int page) throws
            PrinterException {
        if (page > 0) {
            return NO_SUCH_PAGE;
        }

        Graphics2D g2d = (Graphics2D) g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());
        //g.drawString(formated, 100, 100);
        table.printAll(g);

        return PAGE_EXISTS;
    }

    public void actionPerformed(ActionEvent e) {
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPrintable(this);
        boolean ok = job.printDialog();
        if (ok) {
            try {
                job.print();
            } catch (PrinterException ex) {
            }
        }
    }
}

Out of seven columns, this is what prints out:

Link for Picture

Does anybody know why it isn't printing the full table? Thanks for the help in advance.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • I assume you don't know that `JTable` has it's own printing support, [for example](http://stackoverflow.com/questions/14544013/how-to-print-a-jtable-object-in-the-java-application/14544898#14544898) and [example](http://stackoverflow.com/questions/24294117/get-jtable-to-print-tabular-format/24297085#24297085) and if that wasn't enough, there's even a section about at the offical [How to use tables](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#printing) tutorial to help you get started – MadProgrammer Feb 24 '17 at 03:21
  • Thanks a bunch MadProgrammer. Sorry for duplicate question, I couldn't find the answer but apparently it was there. – Samuel Brice Feb 24 '17 at 04:12

0 Answers0