简体   繁体   中英

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). 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.

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. .

I never learned how to create reports in Java, since in the AP Computer Science class that taught java they never covered that. 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. Concerning your report , it would then be a pageable table showing the 1st 50 entries of your dataset. 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. For JavaFX you have to do it on your own (or use some open source tutorial project as base for it).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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