Thursday, March 8, 2012

The easy way to print jtable using library "PrintPreview"

Well, i will show you how you can print jTable component with ease. Let's start.
First of all, you need an IDE , so you can ease manage your source code and import the library. i assume, you know how to import class library from IDE netbeans, just google it!!!.... :)

Ok, what does the library do??.... well, it can print your jTable component and preview the layout before you print them, ofcourse... i have add some function like zooming, import to image jpg and png extension capability. Check it out right now... :)



Here is step by step:
  1. Open up your netbeans ide, now create new form. Drag and drop component jTabel to your form.
  2. Add two button, first button for printing and second button for autoAdjustColumnWidth
  3. here is the screenshoot
  
The Source Code


Here is the screenshot when i run the code:
  1. When i click PrintPreviewJTable button i get this result
  2. When i click autoAdjustColumnWidth button i get this result
Download the complate project and class library printPreview here classlibrary.printPreviewJTable.zip
Any Question?..... just post it here.... see ya... :)

4 comments:

  1. Well, it call's " Myg3nxTable " that does not exist in the project.

    Without it, it seems to me thar i can not try it.

    Best regards, from, Alfredo Fernandes

    ReplyDelete
  2. the class Myg3nxTable is in the library, if you are using new netbean ide (ver. 7.x.x), you need to re-import the library to refresh the class.

    the library is in the pathaddress classlibrary.printme.zip\printme\dist\lib\printpreview.jar

    and the demo aplication is in the pathaddress classlibrary.printme.zip\printme\dist

    i hope, this will help... :)

    ReplyDelete
  3. Thanks. but i cant organized table columns on A4 size.
    how can i resize it?

    ReplyDelete
    Replies
    1. what did you mean? i dont u nderstand... hmmm, did you mean to make long column to single page preview (a4 size) or change the paper to a4 size for printing (so long column will be split to next page)?...

      For this time, you cannot resize the column in preview layout... (well, that is my work todo list for future improvment... :))

      thanks

      Delete