Java – how do I get a custom space between JList projects?

I've added several images to my JList, and now I'm showing their level. Now I want to increase the space between the images in the list? Can you advise me to do this?

Solution

Set a fixed width and height for your JList item

list.setFixedCellHeight(50);
list.setFixedCellWidth(100);

The setborder () method is used to set border insertion You can also add it to the row above to arrange the margin space:

list.setBorder(new EmptyBorder(10,10,10));
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>