如何使JTable的背景透明? [英] How to make the background of a JTable transparent?
本文介绍了如何使JTable的背景透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
Java swing表透明度
Possible Duplicate:
Java swing Table transparency
使JTable背景透明不是那么容易.我只想查看单元格的文本内容.
It is not so easy to make a JTable background transparent. I want to see only the text content of my cells.
推荐答案
如果表本身或单元格都不透明,则该表将是透明的:
The table will be transparent if neither itself nor the cells are opaque:
table.setOpaque(false);
((DefaultTableCellRenderer)table.getDefaultRenderer(Object.class)).setOpaque(false);
如果表格位于ScrollPane
中,则也要使其透明:
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...
这篇关于如何使JTable的背景透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文