Java Reference
In-Depth Information
layout.putConstraint(SpringLayout.WEST, left, 10, SpringLayout.WEST,
contentPane);
layout.putConstraint(SpringLayout.NORTH, left, 25, SpringLayout.NORTH,
contentPane);
layout.putConstraint(SpringLayout.NORTH, right, 25, SpringLayout.NORTH,
contentPane);
layout.putConstraint(SpringLayout.WEST, right, 20, SpringLayout.EAST, left);
frame.setSize(300, 100);
frame.setVisible(true);
}
};
EventQueue.invokeLater(runner);
}
}
Summary
This chapter introduced AWT's predefined layout managers FlowLayout , BorderLayout ,
GridLayout , GridBagLayout , and CardLayout , as well as Swing's predefined layout managers
BoxLayout , OverlayLayout , ScrollPaneLayout , ViewportLayout , and SpringLayout . You saw how
the various alignment settings affect the components within a container whenever you use a
layout manager such as BoxLayout or OverlayLayout . In addition, you were introduced to the
SizeRequirements class, which is used internally by BoxLayout and OverlayLayout .
In Chapter 11, you'll look at the JScrollPane and JViewport containers, which use the
ScrollPaneLayout and ViewportLayout managers, plus several other sophisticated Swing
container classes.
Search WWH ::




Custom Search