12.18.1 FlowLayout
FlowLayout is the simplest layout manager. GUI components are placed in a container from left to right in the order in which they’re added to the container. When the edge of the container is reached, components continue to display on the next line. Class FlowLayout allows GUI components to be left aligned, centered (the default) and right aligned.
The application of Figs. 12.39–12.40 creates three JButton objects and adds them to the application, using a FlowLayout. The components are center aligned by default. When the user clicks Left, the FlowLayout’s alignment is changed to left aligned. When the user clicks Right, the FlowLayout’s alignment is changed to right aligned. When the user clicks Center, the FlowLayout’s alignment ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access