• 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

JScollPane, JtextArea, Opaque Question

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen this issue questioned a few times of different boards, but never seen and answer.
Senario: Frame - Panel - BoxLayout - JscrollPane - JtextArea.
Everything but the frame has obj.setOpaque(false); All other items work correctly and allow the background of the Frame to be seen under any and all objects, except the JScollPane/JtextArea.
Is there a way to 'force' [sic] the JScrollPane and/or the JTextArea to actually perform as the setOpaque(false) should normally? Or is this some 'attribute'/bug of JScrollPane/JtextArea?
I figure it's the JScrollPane because I can manipulate the JTextArea as I choose. But otherwise the JScrollPane (and the JTextArea when Opaque is set to false) show the default gray color and not the Frame background color as specified.
And clues would be helpful.
Thanks
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, you've got most of the solution already. The only thing you're missing is that JScrollPane actually has a hidden component - the JViewport. So you have to set both the JScrollPane *and* it's JViewport to not be opaque.

In the following example the background of the JFrame's content pane is set to green and every component in it has setOpaque( false ) called on it so you end up with a scrollable green JTextArea -

 
reply
    Bookmark Topic Watch Topic
  • New Topic