From the course: Learn Java with Swing

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Layout managers

Layout managers - Java Tutorial

From the course: Learn Java with Swing

Start my 1-month free trial

Layout managers

- [Instructor] Layout managers within Swing. Layout managers are classes that control the size and the location of each of the components that are added to a container. The default layout that you'll see when you're using NetBeans is the FlowLayout. The FlowLayout adds elements from left to right until there's no more room, then it wraps to the next line. Layout managers are important, because they simplify the task of positioning and sizing components, and because they allow you to create flexible user interfaces. Swing provides many different layout managers. We have the BorderLayout, which splits the view into five areas. The very top part is called north, the bottom is south, to the right is east, to the left is west, and then the block in the middle is going to be called center. We have the BoxLayout, which stacks components. The components are stacked on top of each other or placed in a row. The CardLayout is unique in that it manages multiple components that share the same…

Contents