Solved

Printing problem

Posted on 2004-11-01
277 Views
Last Modified: 2008-02-26
I have created a report by using JTable in a JPanel, I want to print the contents of JPanel. could you guys pls help me to do this?.

I did use

PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);


But I am getting the error message:

ReportUI.java [648:1] cannot resolve symbol
symbol  : method setPrintable (ReportUI)
location: class java.awt.print.PrinterJob
        printJob.setPrintable(this);
                ^


what will be the peoblem?.
0
Question by:tstName
    8 Comments
     
    LVL 13

    Expert Comment

    by:petmagdy
    "this" is not of Type ReportUI
    0
     

    Author Comment

    by:tstName
    "this" is not of Type ReportUI" is the message that i got from java, my problem is to get print the panel contents, the panel includes table data and label data.
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    sorry my mistake

    ok if ur class implemetns Printable do this

    printJob.setPrintable( (Printable) this );



    0
     

    Author Comment

    by:tstName
    printJob.setPrintable( (Printable) this ); // this statement will give cast exception
    0
     
    LVL 13

    Accepted Solution

    by:
    then ur ReportUI dosn't implement Printable, that is the cause of the problem
    0
     
    LVL 5

    Expert Comment

    by:JK2429
    0
     

    Author Comment

    by:tstName
    i have a swing Form with JPanel and a JTable.JPanel contain Header and footer informatin for a report, JTable contain  100's of records, i need to print the Jpanel and JTable data. JTable is a Scrollable table, 20 records will display at a time.pls help me to solve this issue.
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    Let ReportUI implements Printable as the link given by JK2429
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Title # Comments Views Activity
    Java virtual machine monitoring tools 3 21
    wordsWithoutList  challenge 24 43
    sumHeights  challenge 17 35
    nestparen challenge 4 20
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now