The application is designed to pull information to fill out a form from a database or write to a database from this form. Right now I can get along with those who use netbeans and turned to my MySQL test server, which I have and is working at the moment.
The problem I am facing is that I need to print the information received from the database in a form similar to the manner, and not a table, in order to match the manually written forms that we now use in the office. Is there a way to print all of the JFrame, or all of the content in the JFrame, just as they are laid out on the screen for viewing by the user?
Everything that I have seen so far will either print the screen area (text box) or print it through a table.
The application will be compiled for both Linux and Windows, when everything is said and done.
the code:
package Information; import java.awt.print.*; import java.awt.*; import javax.swing.*; public class HATDB extends javax.swing.JFrame implements Printable { JFrame frameToPrint; public HATDB() { } @Override public int print(Graphics g, PageFormat pf, int page) throws PrinterException { if (page > 0) { return NO_SUCH_PAGE; } Graphics2D g2d = (Graphics2D) g; g2d.translate(pf.getImageableX(), pf.getImageableY()); frameToPrint.printAll(g); return PAGE_EXISTS; } public HATDB(JFrame f) { frameToPrint = f; } private void OK_ButtonActionPerformed(java.awt.event.ActionEvent evt) { PrinterJob job = PrinterJob.getPrinterJob();
Friendlyghost89
source share