Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1246 > unrolled thread

How to print a JTextArea?

Started by"layne79" <layne79@THRWHITE.remove-dii-this>
First post2011-04-27 15:32 +0000
Last post2011-04-27 15:32 +0000
Articles 5 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  How to print a JTextArea? "layne79" <layne79@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: How to print a JTextA "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
      Re: How to print a JTextA "layne79" <layne79@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
        Re: How to print a JTextA "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
      Re: How to print a JTextA "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000

#1246 — How to print a JTextArea?

From"layne79" <layne79@THRWHITE.remove-dii-this>
Date2011-04-27 15:32 +0000
SubjectHow to print a JTextArea?
Message-ID<1174409505.577869.303580@p15g2000hsd.googlegroups.com>
  To: comp.lang.java.gui
Hello,
I'm trying to implement a printing mechanism for JTextArea but I have
a problem on extracting lines from it.
I used the xample found at http://java.sun.com/docs/books/tutorial/2d/printing/set.html
(PaginationExample class) but, instead of having available an array of
String (textlines), I have a JTextArea.
I need to replace the instruction

 g.drawString(textLines[line], 0, y);

at line 93

with another, taking lines from the textarea.

Dou you know how I can do that?

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#1249 — Re: How to print a JTextA

From"Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this>
Date2011-04-27 15:32 +0000
SubjectRe: How to print a JTextA
Message-ID<1174439230.149042.105820@n76g2000hsh.googlegroups.com>
In reply to#1246
  To: comp.lang.java.gui
layne79 wrote:
> Hello,
> I'm trying to implement a printing mechanism for JTextArea but I have
> a problem on extracting lines from it.
> I used the xample found at http://java.sun.com/docs/books/tutorial/2d/printing/set.html
> (PaginationExample class) but, instead of having available an array of
> String (textlines), I have a JTextArea.
> I need to replace the instruction
>
>  g.drawString(textLines[line], 0, y);
>
> at line 93
>
> with another, taking lines from the textarea.
>
> Dou you know how I can do that?

Layne,

Ever since JDK1.6 the JTextArea has a method called getPrintable that
it gets from JTextComponent. You could start there instead of writing
your own printable.

Cheers,
Dan Andrews
---------------------------
http://www.ansir.ca

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1251 — Re: How to print a JTextA

From"layne79" <layne79@THRWHITE.remove-dii-this>
Date2011-04-27 15:32 +0000
SubjectRe: How to print a JTextA
Message-ID<1174470834.945420.258190@y66g2000hsf.googlegroups.com>
In reply to#1249
  To: comp.lang.java.gui

Dan Andrews ha scritto:

> layne79 wrote:
> > Hello,
> > I'm trying to implement a printing mechanism for JTextArea but I have
> > a problem on extracting lines from it.
> > I used the xample found at http://java.sun.com/docs/books/tutorial/2d/printing/set.html
> > (PaginationExample class) but, instead of having available an array of
> > String (textlines), I have a JTextArea.
> > I need to replace the instruction
> >
> >  g.drawString(textLines[line], 0, y);
> >
> > at line 93
> >
> > with another, taking lines from the textarea.
> >
> > Dou you know how I can do that?
>
> Layne,
>
> Ever since JDK1.6 the JTextArea has a method called getPrintable that
> it gets from JTextComponent. You could start there instead of writing
> your own printable.

Sorry but I can't use JDK 1.6
May you suggest an alternative?
Thank you and bye.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1256 — Re: How to print a JTextA

From"Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this>
Date2011-04-27 15:32 +0000
SubjectRe: How to print a JTextA
Message-ID<1174499644.500173.32720@n59g2000hsh.googlegroups.com>
In reply to#1251
  To: comp.lang.java.gui
> Sorry but I can't use JDK 1.6
> May you suggest an alternative?
> Thank you and bye.- Hide quoted text -

Personally, I'd likely implement a Printable that used the text area's
paint component method. The drawback is that you would need to
calculate the page breaks. There are lots of examples on the internet.
Here is a link to one solution that you can get to by a google for the
terms Printable JTextArea.

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=212065

Cheers,
Dan Andrews
---------------------------
http://www.ansir.ca

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1268 — Re: How to print a JTextA

From"Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this>
Date2011-04-27 15:32 +0000
SubjectRe: How to print a JTextA
Message-ID<4601eff7$0$24754$4c368faf@roadrunner.com>
In reply to#1249
  To: comp.lang.java.gui
Dan Andrews wrote:
> layne79 wrote:
>> Hello,
>> I'm trying to implement a printing mechanism for JTextArea but I have
>> a problem on extracting lines from it.
>> I used the xample found at http://java.sun.com/docs/books/tutorial/2d/printing/set.html
>> (PaginationExample class) but, instead of having available an array of
>> String (textlines), I have a JTextArea.
>> I need to replace the instruction
>>
>>  g.drawString(textLines[line], 0, y);
>>
>> at line 93
>>
>> with another, taking lines from the textarea.
>>
>> Dou you know how I can do that?
> 
> Layne,
> 
> Ever since JDK1.6 the JTextArea has a method called getPrintable that

Ever since? You say that like 1.6 has been out for ages when in fact 
it's the latest version available and only came out within the last few 
months.

> it gets from JTextComponent. You could start there instead of writing
> your own printable.
> 
> Cheers,
> Dan Andrews
> ---------------------------
> http://www.ansir.ca
>

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web