CSDN博客

img programlover

在java中实现对FORM的打印功能

发表于2001/10/7 9:48:00  533人阅读

在JAVA实现对FORM的打印功能

public void print(JFrame frame)
{
  Container container=frame.getContentPane();
  Properties prop=new Properties();

  PrintJob job = getToolkit().getPrintJob(frame,"test",prop);
  // PrintJob job = getToolkit().getPrintJob(this,"test",prop);
  if(job != null)
  {
  Graphics pg = job.getGraphics() ;
  if ( pg != null )
  {
  pg.translate((job.getPageDimension().width-getSize().width)/2,
  (job.getPageDimension().height-getSize().height)/2);
  //old code - container.print(pg);
  print(pg);
  pg.dispose() ;

  job.end();
  }
  }
  job=null;
}

阅读全文
0 0

相关文章推荐

img
取 消
img