Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / May 2005

Tip: Looking for answers? Try searching our database.

How do I change background color of JTable, when setBackground doesn't work?

Thread view: 
tomzam@gmail.com - 30 May 2005 02:51 GMT
    I have a JTable that I am displaying in a JScrollpane. The JTable only
displays a few rows of information in its grid. The space below the
grid to the bottom of the JPanel,
that contains the JScrollpane, (Which in turn contains the JTable) is
colored solid gray.
I'd like to change that color to white. I tried setting the JTable's
background color to
white, [using the method setBackground(Color,WHITE)  ]  but that didn't
work.

    Can anyone tell me which method to use to change that gray to white?

Second question.

I have a second JPanel that I put Buttons into. The buttons are gray,
which is fine.
But the buttons themselves are on a gray background.

How do I change that background to white?

I guess my general question is: which methods control the color between
components?

Any help will be appreciated
Christian Kaufhold - 30 May 2005 11:41 GMT
>        I have a JTable that I am displaying in a JScrollpane. The JTable only
> displays a few rows of information in its grid. The space below the
[quoted text clipped - 5 lines]
> white, [using the method setBackground(Color,WHITE)  ]  but that didn't
> work.

FAQ.

>        Can anyone tell me which method to use to change that gray to white?
>
[quoted text clipped - 5 lines]
>
> How do I change that background to white?

panel.setBackground

Christian
Roland - 30 May 2005 12:05 GMT
>     I have a JTable that I am displaying in a JScrollpane. The JTable only
> displays a few rows of information in its grid. The space below the
[quoted text clipped - 7 lines]
>
>     Can anyone tell me which method to use to change that gray to white?

Set the background color of the scrollpane's viewport:
   scrollpane.getViewport().setBackground(Color.RED);

> Second question.
>
[quoted text clipped - 6 lines]
> I guess my general question is: which methods control the color between
> components?

setBackground(Color)
setForeground(Color)
setOpaque(boolean)

Some components are transparent (IIRC a JLabel) so setting background
doesn't seem to have an effect, until you use setOpaque(true) on the
component.
Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.