Java-JTable 不显示网格线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14300580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 15:48:21  来源:igfitidea点击:

Java- JTable not showing gridlines

javaswing

提问by basketballhead24

I have displayed a JTable in my JPanel.The JTable is inside a scrollpane. The only problem is the gridlines are not showing up.I tried to use this line of code but it didn't work.

我在 JPanel 中显示了一个 JTable。JTable 位于滚动窗格内。唯一的问题是网格线没有显示出来。我尝试使用这行代码,但没有用。

table.setShowGrid(true);

Below is a picture: Note there are no gridlinesenter image description here

下面是一张图片:注意没有网格线在此处输入图片说明

Thank you in advance.

先感谢您。

回答by Will

Does having an etched border make a difference?

蚀刻边框有区别吗?

table.setBorder(new EtchedBorder(EtchedBorder.RAISED));

EDIT:

编辑:

The default colour of grid-lines seems to be white:

网格线的默认颜色似乎是白色:

table.setGridColor(Color.BLUE)

回答by user2790520

table.setShowHorizontalLines(true);
table.setShowVerticalLines(true);