BorderLayout Question

Is there a way to set BorderLayout so that I will have EAST, WEST, NORTH, SOUTH section but no CENTER section?
[117 byte] By [kevch27a] at [2007-11-27 5:37:01]
# 1
Yes, you don't put anything in the Center section
RedUnderTheBeda at 2007-7-12 15:08:41 > top of Java-index,Java Essentials,New To Java...
# 2
That's what I did, but it ended up having a large empty box in the center. What I would like is to have the EAST section and WEST section border to each other.
kevch27a at 2007-7-12 15:08:41 > top of Java-index,Java Essentials,New To Java...
# 3

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

petes1234a at 2007-7-12 15:08:41 > top of Java-index,Java Essentials,New To Java...