Print Data in Table using Java Tutorial in Netbeans

0
57

Print Data in Table using Java Tutorial in Netbeans

This tutorial is all about Print Data in Table using Java Tutorial in Netbeans. In this tutorial you will learn how to Print Data in Table using Java Tutorial in Netbeans. Printing is useful when it comes to documents like reporting. This tutorial uses Netbeans IDE. Please follow all the steps below to complete this tutorial.

Print Data in Table using Java Tutorial in Netbeans steps.

Create your project by clicking file at the top and then click new project, you can name your project whatever you want. But i suggest to name your project that starts with a Capital letter. when the project is created, right click the Source Packages and then click New Jframe Form. and the default form will be created and then click the source above the form and it will lead you to the source code

After that you need to import this package import java.text.*; type it above your class

then double click your button and add the following code

  1. MessageFormat yourheader = new MessageFormat("Report Print");
  2.  
  3. MessageFormat yourfooter = new MessageFormat("Page{0,number,integer}");
  4.  
  5. try{
  6.  
  7. yourTableName.print(JTable.PrintMode.NORMAL, header , footer);
  8.  
  9. }catch(java.awt.print.PrinterException e){
  10.  
  11. System.err.format("Cannot print %s%n", e.getMessage());
  12.  
  13. }

The MessageFormat class comes from the package that we have imported, in this tutorial we use the header and footer. The yourheader and yourfooter is your instance name. after that we  Declare  try/catch block to catch the error if the program throws an exception. The yourTableName is the instance of a table. after that inside the print function we need to pass three parameters, the first parameter is setting the printing mode to NORMAL and the last two parameters are your header and footer instance to get the format of the message

 

For questions or any other concerns or thesis/capstone creation with documentation, you can contact me through the following:

E-Mail: [email protected]

Facebook: facebook.com/RyyanSalem

Contact No.: +639098911050

Ryan A. Salem

BSIT Graduate, soon to be MIT.

Java Developer / System Developer

Related topic(s) that you make like:

1.)Display Image using File Chooser
2.) Create a login form in java


Facebook Comments
(Visited 59 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here