I have a formatting question for my Java swing application. It should be fairly straightforward, but I am having difficulty finding any aid (Every topic seems to be regarding removing any default padding in JPanel). The text in my various JPanels hug the sides and top, touching the colored borders: how can I add padding? Thank you.
Set an EmptyBorder
around your JPanel
.
Example:
JPanel p =new JPanel();
p.setBorder(new EmptyBorder(10, 10, 10, 10));