Using JDK 1.1.8, how can I print a JTree component (in a JScrollPane), which is longer than one page?
When a JTree component is inside a JScrollPane it still has its preferredSize. Thus you could do the following -
- Get a PrintJob.
- Get the dimensions of a printed page.
- Check how many pages (cells ? rows and columns) of pages will cover the rectangle of the JTree's size.
- In two nested loops - one for the rows and one for columns get the graphics from the PrintJob for each cell. Traslate the graphics to the right coordinates of the cell. Set the cliprect to the page size. Call the JTree's print method with that graphics.