• 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

JTextArea line wrap

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is deceptively simple, I am just trying to have a background
image to a JTextArea that will line wrap its text. The line wrap
seems to be only available if a JScrollPane is wrapped around
the JTextArea, but the JViewPort of the JScrollPane turns off
the transparency of the JTextArea, blocking the image.
I have tried having the JScrollPane view the panel with the
JTextArea on the panel, but the text ceases to wrap
and the JTextArea has to be scrolled which distorts the
image.
The relevant code is:

This is all part of a JWindow that shows quotes from the ancient Greeks
over an image of the poet Homer. ImagePanel is an extension of JPanel
that has an image as a background. getNextQuote() returns a quote from
a text file.
Thanks,
Edward
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you need to do is call setOpaque( false ) three times, first on your text area, then on your JScrollPane, then on the JViewport that the text area is in. Then you should be able to just add the scroll pane to your image panel and I think it'll work.
Jeff
 
Edward Brode
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, thanks Jeff! Someone suggested the JScrollPane.getViewport().setOpaque(false), but not the JScrollPane.setOpaque(false) as well.
Thanks again,
Edward
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic