public static void main(String[] args) {
// TODO code application logic here
JFrame frame = new JFrame();
SpringLayout layout = new SpringLayout();
frame.getContentPane().setLayout(layout);
TitledBorder border = null;
border = BorderFactory.createTitledBorder("Group1");
frame.setSize(620, 620);
JPanel mainPanel = new JPanel();
mainPanel.setBorder(border);
//mainPanel.setPreferredSize( new Dimension(600,600));
layout.putConstraint(SpringLayout.EAST, mainPanel, -15, SpringLayout.EAST, frame.getContentPane());
layout.putConstraint(SpringLayout.WEST, mainPanel, 15, SpringLayout.WEST, frame.getContentPane());
layout.putConstraint(SpringLayout.SOUTH, mainPanel, -15, SpringLayout.SOUTH, frame.getContentPane());
layout.putConstraint(SpringLayout.NORTH, mainPanel, 15, SpringLayout.NORTH, frame.getContentPane());
frame.getContentPane().add(mainPanel);
frame.setVisible(true);
}
i am working on the effect with a panel auto-resize along with its parents while its parent resized in java 1.4.2. I used the SpringLayout to do this, but i found that if i define the SpringLayout.East and SpringLayout.South after the WEST and NORTH, the panel (mainPanel) will not posit at (15,15). It will do if EAST and NORTH are defined in front of WEST and SOUTH. Why is that?