@@ -0,0 +1,2683 @@
+package edu.cmu.cs.diamond.rsna2007;%0A%0Aimport java.awt.Color;%0Aimport java.awt.Container;%0Aimport java.awt.Dimension;%0Aimport java.awt.FontMetrics;%0Aimport java.awt.Graphics;%0A%0Aimport javax.swing.Box;%0Aimport javax.swing.JFrame;%0Aimport javax.swing.JPanel;%0Aimport javax.swing.SpringLayout;%0A%0Apublic class LayoutTest extends JFrame %7B%0A    public static class SizePanel extends JPanel %7B%0A        @Override%0A        protected void paintComponent(Graphics g) %7B%0A            super.paintComponent(g);%0A%0A            int w = getWidth();%0A            FontMetrics fm = g.getFontMetrics();%0A            String s = Integer.toString(w);%0A            g.drawString(s, 5, fm.getMaxAscent());%0A        %7D%0A    %7D%0A%0A    public LayoutTest(boolean spring) %7B%0A        super(%22Test%22);%0A%0A        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A        setLocationByPlatform(true);%0A%0A        if (spring) %7B%0A            doSpring();%0A        %7D else %7B%0A            doBox();%0A        %7D%0A%0A        pack();%0A        setVisible(true);%0A    %7D%0A%0A    private void doBox() %7B%0A        Box h = Box.createHorizontalBox();%0A        %0A        SizePanel j1 = makeSizePanel1();%0A        h.add(j1);%0A%0A        h.add(Box.createHorizontalStrut(10));%0A        %0A        SizePanel j2 = makeSizePanel2();%0A        h.add(j2);%0A%0A        add(h);%0A    %7D%0A%0A    private SizePanel makeSizePanel2() %7B%0A        SizePanel p = new SizePanel();%0A        p.setBackground(Color.getHSBColor(0.3f, 0.3f, 0.7f));%0A        p.setMinimumSize(new Dimension(150, 50));%0A        p.setPreferredSize(new Dimension(300, 50));%0A        p.setMaximumSize(new Dimension(600, 50));%0A        return p;%0A    %7D%0A%0A    private SizePanel makeSizePanel1() %7B%0A        SizePanel p = new SizePanel();%0A        p.setBackground(Color.getHSBColor(0, 0.3f, 0.7f));%0A        p.setMinimumSize(new Dimension(100, 50));%0A        p.setPreferredSize(new Dimension(200, 50));%0A        p.setMaximumSize(new Dimension(400, 50));%0A        return p;%0A    %7D%0A%0A    private void doSpring() %7B%0A        Container cp = getContentPane();%0A%0A        SpringLayout layout = new SpringLayout();%0A%0A        setLayout(layout);%0A%0A        SizePanel j1 = makeSizePanel1();%0A        add(j1);%0A%0A        SizePanel j2 = makeSizePanel2();%0A        add(j2);%0A%0A        layout.putConstraint(SpringLayout.WEST, j1, 0, SpringLayout.WEST, cp);%0A        layout.putConstraint(SpringLayout.WEST, j2, 10, SpringLayout.EAST, j1);%0A        layout.putConstraint(SpringLayout.EAST, cp, 0, SpringLayout.EAST, j2);%0A%0A        layout.putConstraint(SpringLayout.NORTH, j1, 0, SpringLayout.NORTH, cp);%0A        layout.putConstraint(SpringLayout.SOUTH, cp, 0, SpringLayout.SOUTH, j2);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        new LayoutTest(true);%0A        new LayoutTest(false);%0A    %7D%0A%7D%0A

add layout test program