我把printMap()解释一下public void printMap() {
//String filename = TMP_FILE;
//获取HTML中的APPLET中的param
String filename = getParameter("Filepath"); //获取HTML文件中的URL路径
//////
String str;
//构建打印请求属性集
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
//设置打印格式,
DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
//查找所有的可用打印服务
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor,
pras);
//定位默认的打印服务
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
//显示打印对话框
PrintService service = ServiceUI.printDialog(null, 200, 200, printService,
defaultService, flavor, pras);
if (service != null) {
try { DocPrintJob job = service.createPrintJob();//创建打印作业
FileInputStream fis = new FileInputStream(filename);//构造待打印的文件流
DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das);//建立打印文件格式
// PageFormat format = job.pageDialog(attributes);
job.print(doc, pras);//进行文件的打印
}
catch (Exception e) {
e.printStackTrace();
} }
} //
public void paint(Graphics g) {
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0, size().width - 1, size().height - 1); //Draw the current string inside the rectangle.
//g.drawString("buffer.toString()", 5, 15); }}
//String filename = TMP_FILE;
//获取HTML中的APPLET中的param
String filename = getParameter("Filepath"); //获取HTML文件中的URL路径
//////
String str;
//构建打印请求属性集
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
//设置打印格式,
DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
//查找所有的可用打印服务
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor,
pras);
//定位默认的打印服务
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
//显示打印对话框
PrintService service = ServiceUI.printDialog(null, 200, 200, printService,
defaultService, flavor, pras);
if (service != null) {
try { DocPrintJob job = service.createPrintJob();//创建打印作业
FileInputStream fis = new FileInputStream(filename);//构造待打印的文件流
DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das);//建立打印文件格式
// PageFormat format = job.pageDialog(attributes);
job.print(doc, pras);//进行文件的打印
}
catch (Exception e) {
e.printStackTrace();
} }
} //
public void paint(Graphics g) {
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0, size().width - 1, size().height - 1); //Draw the current string inside the rectangle.
//g.drawString("buffer.toString()", 5, 15); }}
解决方案 »
- 大神求解。。为什么我的main方法结束后程序还不停止?
- 救急,路过也请进来,java 实现的打印!
- 怎样用java语句实现 类似QQ表情的弹出窗口?
- 菜鸟问题,关于String数组
- 为何connection中的ResultSet.HOLD_CURSORS_OVER_COMMIT无法使用
- 请教高手回答一个问题!
- 我是一个初学者,能不能告诉我,J++ 编译器与 jb 编译器的区别
- linux下不支持java的多线程吗?80分送上
- No buffer space available (maximum connections reached?): recv failed
- 大佬帮看看这些方法的return是返回到哪里 toString是什么意思
- 求救!!!帮帮我好吗?
- 为什么不能向XML文件中的空结点中添加子结点?
那里有很多高手乐意帮忙.也有刚出道的少年. QQ群 号码:4025186