• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to print the contents of a JTextArea  RSS feed

 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
Can anyone tell me how to print the contents of a JTextArea ?
Thank you
Siva
 
Peter Lyons
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JTextArea extends JTextComponent, so you should be able to use getText(), which returns a String. Then you can print that.
Doesn't that work?
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter:
i guess i was not clear enough abt my problem . I wanna print the contents of my TextArea in my printer using PrinterJob class
can u help me pls
rgds siva
Originally posted by Peter Lyons:
A JTextArea extends JTextComponent, so you should be able to use getText(), which returns a String. Then you can print that.
Doesn't that work?

 
Madhusoothanan K
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can store the contents of a text area into a file and then u can send that file for printing.
madhu
 
Colin Kenworthy
Ranch Hand
Posts: 88
 
K Akshay
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at http://www.activetree.com that prints, PDF, TIFF, JPEG, and PNG for JTextPane, JTextArea, JTextComponent and Other kind of Swing and non-swing Report generation.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!