• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing to something besides the console

 
Greenhorn
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Which class is best to use if I want to output text, but not to the console? I'd like to give the user the output in a nice, formatted manner with a specific font. The output will be approximately one page worth of text. I'd like to be able to scroll, so I'll need JScrollPane too. Or is there a better way?

I've been reading about JTextArea, but I don't know if that is the best way to go about this.

Cheers

BD
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd use either a JTextArea for plain text, or a JTextPane if you need to add formatting.
 
Bd Howard
Greenhorn
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob. Sorry for the late reply, but I've been focused on writing a C program for another class. :-(

Much prefer Java. :-)

BD
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
And having been busy with some JNI myself the last few days I have to agree with you.
 
Bd Howard
Greenhorn
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To continue on this thought.......

I have my JTextPane working, all of my output looks good, so now I am trying to extend my knowledge. Is there a way to change the font color of individual words? I see how to change the color of everything in the Pane, but I want more granularity. For example, to add emphasis to a result such as:

The number of comparisons was 412




Can color specs be added to a Style or a SimpleAttributeSet, so whenever that Style (or SimpleAttributeSet) is used, the text is colored? It would seem to be a simple solution if I could just apply a Style to the outputting of that variable that resolves to 412, but I don't know if that is possible.

Cheers

BD
 
Bd Howard
Greenhorn
Posts: 80
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found what I was looking for. I was too quick to give up on my search. :-(

BD
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic