The attached patch provides correct borders for the Windows L&F (including 2k, XP & Vista) for use by DefaultListCellRenderer and DefaultTableCellRenderer. It also adds a 1-pixel empty border to JList. For screenshots before and after the fix, see http://benloud.com/Borders.png.
This addresses a couple of problems with the default list and table cell renderers. The first problem is that the no-focus border is null, so the text appears right up against the edge. The second problem is that since the focussed border has 1-pixel thick insets (vs no insets when non-focussed), the text position shifts to the right by 1 pixel when the cell is selected. When fixing this, I didn't want to change the preferred height of cells, so the top and bottom insets are unchanged. This also closely matches the cell heights in native windows. But the left and right insets now have correct padding (2 pixel empty when non-focussed, 1 pixel dashed + 1 pixel empty when focussed). The left and right insets are now the same between focussed and non-focussed states, so the text doesn't move. Table cells are given the same borders, but the table itself still has no border. This also closely matches native windows. Now, important note: When doing this, I needed support for a no-focus cell border UI property for Tables to add an empty border that ensures the left/right padding is consistent between focussed and non-focussed states. But no such property exists in the current OpenJDK sources. I almost submitted a patch to add it, until I noticed it has already been added in JDK6u10. I also noticed that in JDK6u10, the name of the List cell no-focus border has changed! So what I decided to do was submit this patch using the names as they are in update 10. Hopefully the change in 6u10 will make its way in to OpenJDK7 very soon, and when that happens, and they will pick up these new properties and things will look fine. Until then, this patch has little effect.
borders.patch
Description: borders.patch