Welcome to Dream.In.Code
Become a Java Expert!

Join 149,713 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,253 people online right now. Registration is fast and FREE... Join Now!




background of a JTable

 
Reply to this topicStart new topic

background of a JTable

alpha02
11 Feb, 2007 - 04:57 PM
Post #1

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
Hi all! I am using a JTable to show some information, like this:

Attached Image

(the red smiley was added in Paint tongue.gif )

All right, the cells' backgrounds are white, but the remaining part is solid gray. I want all the background to be white, like in a listview. Anyone got a tip for that? I used the JTable.setBackground() method but only the cells are affected.

Thanks in advance.
User is offlineProfile CardPM
+Quote Post

Ellie
RE: Background Of A JTable
12 Feb, 2007 - 11:45 AM
Post #2

D.I.C Regular
Group Icon

Joined: 17 Jan, 2007
Posts: 427



Thanked: 4 times
Dream Kudos: 150
My Contributions
QUOTE(alpha02 @ 12 Feb, 2007 - 12:57 AM) *

Hi all! I am using a JTable to show some information, like this:

(the red smiley was added in Paint tongue.gif )

All right, the cells' backgrounds are white, but the remaining part is solid gray. I want all the background to be white, like in a listview. Anyone got a tip for that? I used the JTable.setBackground() method but only the cells are affected.

Thanks in advance.


I think that that area doesn't belong to the JTable, but to whatever component it is placed it in.

According to this:
http://www.chka.de/swing/table/faq.html
QUOTE

How can I set the background color below (and to the right) of table cells if there are few rows (or colums)?

These areas don't belong to JTable by default. Instead its JViewport parent shows through there. You may either set a background color on the JViewport:

table.getParent().setBackground(...);
// table.getParent().setOpaque(true); if possibly turned off somewhere else

or use something like described in the Drag-and-Drop section to make the JTable higher/wider.



User is offlineProfile CardPM
+Quote Post

alpha02
RE: Background Of A JTable
12 Feb, 2007 - 01:28 PM
Post #3

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
QUOTE(Ellie @ 12 Feb, 2007 - 02:45 PM) *

QUOTE(alpha02 @ 12 Feb, 2007 - 12:57 AM) *

Hi all! I am using a JTable to show some information, like this:

(the red smiley was added in Paint tongue.gif )

All right, the cells' backgrounds are white, but the remaining part is solid gray. I want all the background to be white, like in a listview. Anyone got a tip for that? I used the JTable.setBackground() method but only the cells are affected.

Thanks in advance.


I think that that area doesn't belong to the JTable, but to whatever component it is placed it in.

According to this:
http://www.chka.de/swing/table/faq.html
QUOTE

How can I set the background color below (and to the right) of table cells if there are few rows (or colums)?

These areas don't belong to JTable by default. Instead its JViewport parent shows through there. You may either set a background color on the JViewport:

table.getParent().setBackground(...);
// table.getParent().setOpaque(true); if possibly turned off somewhere else

or use something like described in the Drag-and-Drop section to make the JTable higher/wider.




Thanks, that's exactly what I was looking for!
User is offlineProfile CardPM
+Quote Post

Ellie
RE: Background Of A JTable
13 Feb, 2007 - 02:31 AM
Post #4

D.I.C Regular
Group Icon

Joined: 17 Jan, 2007
Posts: 427



Thanked: 4 times
Dream Kudos: 150
My Contributions

Yay, no worries biggrin.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 04:38AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month