basketballhead24
basketballhead24

Reputation: 141

Java- JTable not showing gridlines

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.

table.setShowGrid(true);

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

Thank you in advance.

Upvotes: 8

Views: 13247

Answers (2)

user2790520
user2790520

Reputation: 121

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

Upvotes: 12

Will
Will

Reputation: 6286

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)

Upvotes: 12

Related Questions