Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Background color of viewport doesn't work

 
Arman Charif
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have tried setting the background color of a scroll pane's viewport, but this doesn't work.. The unused viewport remains grey. Can anyone tell what i'm doing wrong? Thanks in advance for any help.

Here's my code.

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The unused portion is not actually part of the ViewPort. The ViewPort only consists of the component that is viewable inside the ScrollPane. Try setting the background color of the JScrollPane to the same color as the viewport and see if that does the trick.
 
Arman Charif
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg,

Thanks for your reply. I've tried to set the background color of the scroll pane as well, but it didn't work either. In fact i've tried so many things now that i can't think of anything else to try...

The scroll pane is in a class that extends a JPanel. I've also tried to set the JPanel's bg color but doing so makes no difference.. Do you know what could be the cause of this problem?

Arman
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!