I have added few images to my JList showing them horizontally.
Now I want to increase the space between the images in the JList.
Could anyone suggest how to do it?
Set a fixed width and height for your JList items.
list.setFixedCellHeight(50);
list.setFixedCellWidth(100);
The setBorder()
method is for setting border insets. You can also add it to the lines above to make margin spaces arranged:
list.setBorder(new EmptyBorder(10,10, 10, 10));
提供您自己的ListCellRenderer
,它可以引入例如具有特定宽度的空边框。
there are two ways
1) Renderer
can returns JLabel
, set EmptyBorders()
2) a little bit complicated way is put there JSeparator
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.