zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java的打印技术

JAVA技术 打印
2023-09-11 14:20:31 时间
Java的打印功能 DeveloperWork上分享的一篇讲解Java打印技术的文章 和  Oracle上的关于Printing的Guide : 主要用到两个包 java.awt.print and javax.print The basic printing operations are represented in the following sections: A Basic Printing Program – this section describes the Printable interface and presents a basic printing program. Using Print Setup Dialogs– this sections explains how to display the Print Setup Dialog. Printing a Multiple Page Document – this section explains how to use pagination for printing a multiple page document. Working with Print Services and Attributes ndash; this section teaches you about print services, how to specify the print data format, and how to create print job using the javax.print package. Printing the Contents of a User Interface – this section explains how to print the contents of a window or a frame. Printing Support in Swing Components - this section provides a brief description of the related printing functionality inSwing and refers to specific Swing classes and interfaces. Java打印技术的核心代码,可以参考下面的HelloWOrldPrinter,基本上来说就是建立PrinterJob与Printable接口的关系即可。
import java.awt.print.*; public class HelloWorldPrinter implements Printable, ActionListener { public int print(Graphics g, PageFormat pf, int page) throws PrinterException { if (page 0) { /* We have only one page, and page is zero-based */ return NO_SUCH_PAGE; /* User (0,0) is typically outside the imageable area, so we must * translate by the X and Y values in the PageFormat to avoid clipping Graphics2D g2d = (Graphics2D)g; g2d.translate(pf.getImageableX(), pf.getImageableY()); /* Now we perform our rendering */ g.drawString("Hello world!", 100, 100); /* tell the caller that this page is part of the printed document */ return PAGE_EXISTS; public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); boolean ok = job.printDialog(); if (ok) { try { job.print(); } catch (PrinterException ex) { /* The job did not successfully complete */ public static void main(String args[]) { UIManager.put("swing.boldMetal", Boolean.FALSE); JFrame f = new JFrame("Hello World Printer"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} JButton printButton = new JButton("Print Hello World"); printButton.addActionListener(new HelloWorldPrinter()); f.add("Center", printButton); f.pack(); f.setVisible(true); 本博在是将JPanel中的内容进行打印,直接将panel实现Printable接口即可,但是打印出来的页面上只有部分的Panel内容,特别是部分横向内容丢失,使用scale进行修正即可。
另外,有一个关于equals方法的小疑问: 出现编译错误:The method equals(VUserGroup) of type VUserGroup must override or implement a supertype method
运用云计算技术的java智慧校园云平台源码 电子班牌系统是全功能智慧管理平台系统,电子班牌系统是以在校人员信息、出勤管理和班级信息展示为主体,为学校教育行业量身设计的一款集云平台、网络数据实时通信技术、物联网技术、智能控制技术、信息发布管理技术为一体的智慧平台系统。
Java函数式编程:一种令人懵逼的技术,但是真的很好用... ....吧? 函数式编程:关注做什么,说白了,内置函数库已经将需要的功能实现好了,直接用。 命令式编程:关注怎么做,具体实现细节需要我们自己代码编写。
完美!腾讯技术官发布Java零基础就业宝典,不用再怀疑人生了 近几年来,互联网行业变化非常大,除了龙头企业的更替,“裁员潮”“失业潮”也不断掀起,尤其是对于年纪太大的程序员真的是不太友好。但是,根据数据统计表明,自2018来,学习IT行业的人不减反增,更有不少其他行业的人转学转行。
又一里程碑!阿里首推Java技术成长笔记,业内评级“钻石级” 根据数据表明,阿里巴巴已经连续3年获评最受欢迎的中国互联网公司,实际上阿里巴巴无论在科技创新力还是社会创造价值这几个方面,都是具有一定代表里的。在行业内,很多互联网企业也将阿里作为自己的标杆,越来越多的“打工人”也希望能够进到阿里工作。
阿里巴巴新产“Java架构核心宝典”,全是流行技术,限时开放 什么是架构师?对于程序员来说,聊架构是一个永不过时的话题。实际上,每一家公司都有自己对架构师不同的定位,因为不同的公司,所处的阶段、业务模式以及应用场景都不一样,因此对架构师的要求不一样,所以定位也就不同。 但是,无论如何,架构师除了优秀的合作能力以及清晰的思路头脑以外,过硬的技术基础也是很有必要的,大型的互联网公司对架构师的技术要求也是非常高的。因此,学习架构技术,刻不容缓。
​Java高精度人员定位系统源码,基于Vue+Spring boot开发,运用UWB定位技术 一套运用UWB技术的高精度人员定位系统源码,专业团队研发,可运用于化工厂人员定位,养老院定位,施工人员定位,隧道人员定位,室内管廊定位,车辆定位,物资定位,仓储定位等。