let's see your code. when i add jpanels at east, west, north and south, i see no gap in the center, and east and west border each other. For instance:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class FoolinWBorderLO extends JFrame
{
JPanel mainPanel = new JPanel();
public FoolinWBorderLO()
{
addWidgets();
getContentPane().add(mainPanel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
// create and add a panel and a button. put in a border so
// panel edges can be more readily seen
private JPanel addPanel(String direction)
{
JPanel directionPanel = new JPanel();
JButton directionButton = new JButton(direction + " Button");
directionButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
String optionStr = ae.getActionCommand() + " has been pressed";
JOptionPane.showMessageDialog(null, optionStr);
}
});
directionPanel.add(directionButton);
directionPanel.setBorder(BorderFactory.createLineBorder(Color.black));
return directionPanel;
}
// here's were I set the main panel's borderlayout and
// add the subpanels at BorderLayout.EAST, .WEST, ...
private void addWidgets()
{
mainPanel.setLayout(new BorderLayout());
mainPanel.add(addPanel("East"), BorderLayout.EAST);
mainPanel.add(addPanel("West"), BorderLayout.WEST);
mainPanel.add(addPanel("North"), BorderLayout.NORTH);
mainPanel.add(addPanel("South"), BorderLayout.SOUTH);
}
private static void createAndShowGUI()
{
FoolinWBorderLO fblo = new FoolinWBorderLO();
fblo.pack();
fblo.setVisible(true);
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
Just please show us a running example of your layout code, one that reproduces your problem.
Thanks,
/Pete