Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16. Swinging Higher > Layout Managers

Layout Managers

A container, such as a JFrame and a JDialog, needs a java.awt.LayoutManager to lay out child components. The LayoutManager resizes and positions all child components, as well as rearranges the components when the container is resized. The java.awt.Container class has a setLayout method you use to add a layout manager. Since javax.swing.JComponent also extends the Container class, you can add a LayoutManager to a Swing component as well. For example, it is not uncommon to add a LayoutManager to a JLabel if the latter has components added to it.

In some components, you can pass a LayoutManager to the component class. This is the case for JPanel.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint