You have to use the Printing API. You can check out the tutorial
here.
Swing components have printing support. If it is just a JPanel, I think it would be easier. You have to place the components (say labels) using layouts or 'paint' directly using Graphics object. You have to implement the Printable interface which has a method to return the number of pages left. However, if you need a header/footer + variable information in the middle (that spawns pages), it will be slightly harder.
You can refer these JavaRanch posts (comes up straight in a Google search):
one,
two