This is an example of a JList. I know how to set a border to the entire JList or the panel containing the JList. My question is that how can we create line borders between the cells?`
For example in the given picture the color of the line border between the first cell and the second is grey, while there is a white colored line border between all the other cells.
Please don't say that this is a JComboBo
x or a JTree
(because of the second element and its two children); even if it is not a JLis
t, I want my JList
to have similar LineBorders
between the cells
.
My web search led me to this interface
. Its method getListCellRendererComponent
takes arguments like E value, int index, boolean isSelected, boolean cellHasFocus
, while I want the LineBorder
to appear between all the cells no matter what index they have and whether they are selected or not etc.
EDIT:-
The border is thicker in some places and fine in others.