How to make the background of a JTable transparent?
13,096
The table will be transparent if neither itself nor the cells are opaque:
table.setOpaque(false);
((DefaultTableCellRenderer)table.getDefaultRenderer(Object.class)).setOpaque(false);
If the table is in a ScrollPane
, it is to make transparent as well:
scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);
At least, you can remove the grid lines:
table.setShowGrid(false);
Quite a big work for a simply result...
Author by
Olivier Faucheux
Updated on June 04, 2022Comments
-
Olivier Faucheux almost 2 years
Possible Duplicate:
Java swing Table transparencyIt is not so easy to make a JTable background transparent. I want to see only the text content of my cells.