简体   繁体   English

如何创建带有选项的报告以在Java中进行打印和查看

[英]How to create a report with options to print and view in Java

I'm doing an event for a competition for Desktop Application Programming, and I opted to do it using Java, since it's the only language I've learned so far (I'm a high school student). 我正在参加桌面应用程序编程竞赛,因此选择使用Java,因为它是我到目前为止所学的唯一语言(我是一名高中学生)。 The competition is to design a desktop application that lets a user enter records of club members (name, date joined, etc), and store them in a master file. 竞争是设计一个桌面应用程序,使用户可以输入俱乐部成员的记录(姓名,加入日期等),并将其存储在主文件中。 I'm handling the master file aspect by creating objects of type Student, and writing the objects to a text file to save them. 我通过创建类型为Student的对象并将对象写入文本文件以保存它们来处理主文件方面。

The part I'm having issue with is the following: Create a report that will produce a list of members...The report footer should include[...] Have an option to view or print the report, allowing for 50 detail lines per page and at the end of the report, with the footer information described above. 我遇到的问题如下: 创建一个将生成成员列表的报告...报告页脚应包括[...]有查看或打印报告的选项,允许50条明细行每页以及报表的末尾,以及上述页脚信息。 .

I never learned how to create reports in Java, since in the AP Computer Science class that taught java they never covered that. 我从未学习过如何用Java创建报告,因为在教授Java的AP计算机科学课程中,他们从未涉及过这一点。 What are my options for creating reports, and how would I make it so that the report could be printed? 创建报告有哪些选择,我将如何做才能打印报告?

You asks for quite some things and probably you'll have to dive into some technologies before implementing the application. 您需要做很多事情,在实现该应用程序之前,可能必须深入研究某些技术。

If it has to be Java and a Desktop Application, then today JavaFX is the technology of choice. 如果必须是Java和桌面应用程序,那么今天的JavaFX是首选技术。 Concerning your report , it would then be a pageable table showing the 1st 50 entries of your dataset. 关于您的报告 ,它将是一个可分页的表格,显示数据集的前50个条目。 The problem with JavaFX currently is, that it lacks some features in its GUI elements, which are very common when doing web applications and using GUI component libraries like PrimeFaces where this is readily available. JavaFX当前的问题是,它的GUI元素缺少某些功能,这在做Web应用程序和使用GUI组件库(如PrimeFaces)时非常普遍,而这些功能很容易获得。 For JavaFX you have to do it on your own (or use some open source tutorial project as base for it). 对于JavaFX,您必须自己完成(或使用一些开源教程项目作为基础)。

Concerning printing, this is yet another issue. 关于打印,这是另一个问题。 Here your best choice is probably not to use the Printing API directly, but some API to produce a PDF which would allow you to save and print it. 在这里,您最好的选择可能不是直接使用Printing API,而是使用某些API来生成PDF,从而可以保存和打印它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM