1

I have a JTable, and I only show horizontal lines to separate each table row. In Windows 8, the lines show, but in Mac OS X, they don't. I am using a JLabel in a custom cell renderer for all of the cells in the table, and I added a matte border to the JLabel to correct this problem for Mac OS X. However, it doesn't look right because if you look closely in the screenshot below, you can see that the horizontal line is broken (i.e. not contiguous) where one column ends and the other begins. (Look closely between the English and Notes columns.)

enter image description here

How do I add a border to all of the cells in the table such that it looks like the one in the Windows 8 screenshot below?

enter image description here

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
BJ Dela Cruz
  • 5,194
  • 13
  • 51
  • 84

1 Answers1

4

The TableUI delegate on Mac OS X sets both Table.background and Table.gridColor to Color.white, making the grid effectively invisible. You can change the grid color like this:

UIManager.put("Table.gridColor", new ColorUIResource(Color.gray));
EventQueue.invokeLater(new Runnable() {

    @Override
    public void run() {
        // construct your GUI
    }
});
trashgod
  • 203,806
  • 29
  • 246
  • 1,045