31.13. Tree Node Rendering and Editing

 
[Page 961 ( continued )]

Chapter Summary

  • javax.swing.JRootPane is a lightweight container used behind the scenes by Swing's top-level containers, such as JFrame , JApplet , and JDialog . javax.swing.JLayeredPane is a container that manages the optional menu bar and the content pane. The content pane is an instance of Container . By default, it is a JPanel with BorderLayout . This is the container where the user interface components are added. To obtain the content pane in a JFrame or in a JApplet , use the getContentPane() method. You can set any instance of Container to be a new content pane using the setContentPane method.

  • Every container has a layout manager that is responsible for arranging its components. The container's setLayout method can be used to set a layout manager. Certain types of containers have default layout managers.

  • Java provides FlowLayout , GridLayout , BorderLayout , CardLayout , GridBagLayout , BoxLayout , OverlayLayout , and SpringLayout . The layout manager places the components in accordance with its own rules and property settings, and with the constraints associated with each component. Every layout manager has its own specific set of rules. Some layout managers have properties that can affect the sizing and location of the components in the container.

  • Java also supports absolute layout, which enables you to place components at fixed locations. In this case, the component must be placed using the component's instance method setBounds (defined in java.awt.Component ). Absolute positions and sizes are fine if the application is developed and deployed on the same platform, but what looks fine on a development system may not look right on a deployment system on a different platform. To solve this problem, Java provides a set of layout managers that place components in containers in a way that is independent of fonts, screen resolutions , and operating systems.

  • In addition to the layout managers provided in Java, you can create custom layout managers by implementing the LayoutManager interface.

  • Java provides specialized containers Box , JScrollPane , JTabbedPane , and JSplitPane with fixed layout managers.

  • A Swing border is defined in the Border interface. Every instance of JComponent can set a border through the border property defined in JComponent . If a border is present, it replaces the inset. There are eight concrete border classes: BevelBorder , SoftBevelBorder , CompoundBorder , EmptyBorder , EtchedBorder , LineBorder , MatteBorder , and TitledBorder . You can use the constructors of these classes or the static methods in javax.swing.BorderFactory to create borders.

 


Introduction to Java Programming-Comprehensive Version
Introduction to Java Programming-Comprehensive Version (6th Edition)
ISBN: B000ONFLUM
EAN: N/A
Year: 2004
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net