How to make JTable background transparent?

Possible duplicate:
transparency of Java swing tables

It's not easy to make a transparent JTable background. I want to see only the text content of my cells.

+5
source share
1 answer

The table will be transparent if neither itself nor the boxes are opaque:

table.setOpaque(false);
((DefaultTableCellRenderer)table.getDefaultRenderer(Object.class)).setOpaque(false);

If the table is in ScrollPane, it should also be transparent:

scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);

At least you can remove the grid lines:

table.setShowGrid(false);

Pretty big work for a simple result ...

+14
source

All Articles