I'm using a border layout, and each cell except SOUTH in the layout contains a JPanel. Each JPanel contains a few components. All I would like to do is add some padding to the NORTH and SOUTH JPanels and keep them centered....
Or, I want to take this:
How can I add padding either to the JPanels in the NORTH and SOUTH cells, or to the BorderLayout cells?
Of course that really wasn't code, but it was the only way I could find to format it correctly. [ October 18, 2004: Message edited by: Matthew Taylor ]
Joined: May 18, 2004
You can pad every cell in a BorderLayout by using the constructor new BorderLayout(5,5) where 5 is the px of padding you want on every cell.
You can also pad components individually by giving them an empty border (or compound border if you need the line). myComp.setBorder(BorderFactory.createEmptyBorder(top,left,bottom,right));
Joined: Jun 13, 2004
I should have known. Thanks, the EmptyBorder did what I wanted.