import java.awt.Rectangle;
import java.awt.print.PrinterException;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

public class TableTest {
	public static void main(String... args) {
		SwingUtilities.invokeLater(() -> {
			TableModel dataModel = new AbstractTableModel() {
				@Override
				public int getColumnCount() {
					return 10;
				}

				@Override
				public int getRowCount() {
					return 1000;
				}

				@Override
				public Object getValueAt(int row, int col) {
					return Integer.valueOf(0 == col ? row + 1 : row * col);
				}
			};
			JTable table = new JTable(dataModel) {
				@Override
				public Rectangle getBounds() {
					Rectangle bounds = super.getBounds();
 //bounds.y=0; // Workaround - enable this line
					return bounds;
				}
			};
			JScrollPane scrollpane = new JScrollPane(table);
			table.scrollRectToVisible(table.getCellRect(table.getRowCount() - 1, 0, false)); // Enabling this line makes
																								// print only print 90
																								// rows in Java 14
			JFrame f = new JFrame("Table test Java version: " + System.getProperty("java.version"));
			f.add(scrollpane);
			f.setSize(1000, 800);
			f.setLocationRelativeTo(null);
			f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			f.setVisible(true);
			try {
				table.print();
			} catch (PrinterException e) {
				e.printStackTrace();
			}
		});
	}
}