Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Can any body please tell me that how can I print a swing form

  Asked By: Meenachi    Date: May 09    Category: Java    Views: 863
  

Can any body please tell me that how can I print a swing form

e.g. In first form I am selecting user name and after clicking on button,
I want to display details of user as well as print out of that form

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Adanalie Garcia     Answered On: May 09

For printing the details  you can use the BasejDialog facility..

 
Answer #2    Answered By: Ginger Snyder     Answered On: May 09

using printable,
import java.awt.*;
import java.awt.print.*;

public class PrintableComponent implements Printable {
Component c;
public PrintableComponent(Component c) { this.c = c; }

public void print() throws PrinterException {
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat format = job.pageDialog(job.defaultPage());
job.setPrintable(this, format);
if (job.printDialog())
job.print();
}

public int print(Graphics g, PageFormat format, int pagenum) {
if (pagenum > 0)
return Printable.NO_SUCH_PAGE;

Graphics2D g2 = (Graphics2D) g;

g2.transl
c.paint(g2);

return Printable.PAGE_EXISTS;
}
}

 
Answer #3    Answered By: Jimmy Abp     Answered On: May 09

((<WBR>Component c) { this.c

could somebody please explain the difference between ( ) and { }? there are
a couple of programs in my programming book where they use { } instead of (
) in the arguments. Please explain?

does anybody know if the JVM AND Textpad are compatible with Vista yet?

 




Tagged: