1    import javax.swing.*;
2    import java.awt.print.*;
3    import java.awt.*;
4    
5    public class Previewer extends JPanel {
6      Page page;
7      PageFormat format;
8    
9      public Previewer(Page page,PageFormat format) {
10       this.page=page;
11       this.format=format;
12   //        frame.setSize((int)(format.getImageableWidth()+format.getImageableX()*2),
13   //        	      (int)(format.getImageableHeight()+format.getImageableY()*2));
14       setSize(400,400);
15     }
16   
17     public void paint(Graphics g) {
18       View view = new View();
19       view.draw = (Graphics2D)g;
20       page.print(view,format);
21     }
22   }
23