I have to create 5 Jlists in succession to make their backgrounds look in different colors. My existing code creates these 5 lists without the colors (the default JList). I understand that I can only customize the inside/border of a jlist and not the margin/padding around it? Or Am I wrong and is there a way to it?
Btw, The space above the list is a Jlabel (not shown in the pic above) and the layout managers in use are GroupLayout and GridBagLayout.
UPDATE
AT, as per your suggestion, here is a comparison to how the lists look like when surrounded by a jpanel. The lists in the back are the ones with the Jpanel surrounded with a minimal empty border of size 1.
The issue with creating a JPanel with preferredsize overridden is that the jlists are in horizontal jpanel and above them is another jpanel with labels. So, wrapping jlist in a jpanel is not going to do it.
Please do have a look at this code example. Is it closer to what you wanted, else you define the changes that needs to be done. I be on them as soon as I get the reply from your side :-)
Here is the outcome :
**LATEST EDIT : **
As rightly pointed by @kleopatra (not something that is new for me :-)), too good judgement call. Done the edit related to that below :