如何在Jpanel中添加打印功能 小弟在一个jpanel中绘制了一些表格以及相关的数据,这些都是位于“CENTER”区域,我在“NORTH”区域中添加了一个打印按钮,想打印CENTER”区域中的全部内容,总的来说就是实现一个简单的打印功能,不知道大家有没有一些代码样例供小弟参考,感激不尽! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 javax.print包提供的打印功能.下的代码是打一个文件夹,是API上的:FileInputStream psStream;try { psStream = new FileInputStream("file.ps");} catch (FileNotFoundException ffne) {}if (psStream == null) { return;}DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;Doc myDoc = new SimpleDoc(psStream, psInFormat, null); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();aset.add(new Copies(5));aset.add(MediaSize.A4);aset.add(Sides.DUPLEX);PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, aset);if (services.length > 0) { DocPrintJob job = services[0].createPrintJob(); try { job.print(myDoc, aset); } catch (PrintException pe) {}} http://topic.csdn.net/u/20090810/19/23b2236e-a866-4ba0-aa4b-d3630c27abf0.htmlhttp://topic.csdn.net/u/20090812/17/bff1ed0d-b2c0-4908-9531-07a0598aeea9.htmlhttp://topic.csdn.net/u/20090812/19/bf066e6e-484a-4178-bf08-696e8cafb897.htmlhttp://topic.csdn.net/u/20090224/09/00575142-3759-4d29-a67c-7de4eab06d6e.htmlhttp://topic.csdn.net/u/20090812/18/adea1de8-94c9-421d-9e75-a4aff1b8b429.htmlhttp://topic.csdn.net/u/20090812/18/42c30048-e8ac-4864-afbe-2ae0876398b9.htmlhttp://topic.csdn.net/u/20090812/10/d58a5437-5dd6-4be4-82b3-3369ecd0f45e.htmlhttp://topic.csdn.net/u/20090811/14/30481c1f-eb2a-4d7c-a0f0-2e867c7863ed.htmlhttp://topic.csdn.net/u/20090811/15/11f11b5e-da2d-486c-8474-adbe22faaebf.html分流少侠,自己看看吧,全是一样的话,不举例了,其实一个UP就完了,复制粘贴不累啊 JAVA如何读取MTP便携设备中的文件? 百元买百鸡问题。 jtree 中空文件夹问题 关于java编写计算器的问题??? path 和classpath的问题在winxp中 大家看看这个简单的程序输出结果? inlining内联化是什么意思,inlining候选者这又是什么 如何设定JAVA环境??? 一个巨傻的问题 新手上路中,想学JAVA 请推荐入门书啊。散分了啊!!!! 在线等,socket通信! 怎么得到System.out.println的内容
try {
psStream = new FileInputStream("file.ps");
} catch (FileNotFoundException ffne) {
}
if (psStream == null) {
return;
}DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
Doc myDoc = new SimpleDoc(psStream, psInFormat, null);
PrintRequestAttributeSet aset =
new HashPrintRequestAttributeSet();
aset.add(new Copies(5));
aset.add(MediaSize.A4);
aset.add(Sides.DUPLEX);
PrintService[] services =
PrintServiceLookup.lookupPrintServices(psInFormat, aset);
if (services.length > 0) {
DocPrintJob job = services[0].createPrintJob();
try {
job.print(myDoc, aset);
} catch (PrintException pe) {}
}
http://topic.csdn.net/u/20090812/17/bff1ed0d-b2c0-4908-9531-07a0598aeea9.html
http://topic.csdn.net/u/20090812/19/bf066e6e-484a-4178-bf08-696e8cafb897.html
http://topic.csdn.net/u/20090224/09/00575142-3759-4d29-a67c-7de4eab06d6e.htmlhttp://topic.csdn.net/u/20090812/18/adea1de8-94c9-421d-9e75-a4aff1b8b429.html
http://topic.csdn.net/u/20090812/18/42c30048-e8ac-4864-afbe-2ae0876398b9.html
http://topic.csdn.net/u/20090812/10/d58a5437-5dd6-4be4-82b3-3369ecd0f45e.html
http://topic.csdn.net/u/20090811/14/30481c1f-eb2a-4d7c-a0f0-2e867c7863ed.html
http://topic.csdn.net/u/20090811/15/11f11b5e-da2d-486c-8474-adbe22faaebf.html
分流少侠,自己看看吧,全是一样的话,不举例了,其实一个UP就完了,复制粘贴不累啊