Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How Do I Make JTable Header Rows Transparent?

403 views
Skip to first unread message

Ken Carpenter

unread,
Jan 31, 2001, 9:18:36 PM1/31/01
to
I have a JTable with a custom renderer for the header row. I basically just
draw a JLabel with an image in it for each column.

I also have a bitmap in the panel "behind" the table (table is non-opaque).
Everything about the table is transparent as I expected, except the header
row. No matter what combination of setOpaque() and setBackground() calls I
make, even with transparent colors, it still insists on drawing a light gray
background for the header row.

Here's the code that sets the background colors right now:

// Set the background of the scroll view that contains the table
searchResultsScrollPane.getViewport().setBackground(new
Color(0,0,0,0));
searchResultsScrollPane.getViewport().setOpaque(false);

// Set the background of the table
searchResultsTable.setOpaque(false);
searchResultsTable.setSelectionBackground(new Color(211,202,178));
searchResultsTable.setSelectionForeground(Color.black);
searchResultsTable.setBackground(new Color(0,0,0,0));

In the table itself, I can "see through" to the background properly, but not
in the table header row.

Any ideas?

Thanks,


Ken Carpenter


Christian Kaufhold

unread,
Feb 1, 2001, 5:37:35 AM2/1/01
to
Ken Carpenter <new.radiant.net> wrote:

> I have a JTable with a custom renderer for the header row. I basically just
> draw a JLabel with an image in it for each column.

[Header is not transparent]

Untested: table.getTableHeader().setOpaque(false);
scrollPane.getColumnHeader().setOpaque(false);

This seems to work.


Christian

0 new messages