Java Reference
In-Depth Information
The Button objects are positioned by the layout manager flow. As you can see, they have been added
to the first row in the window, and the row is centered. You can confirm that the row is centered and
see how the layout manger automatically spills the components onto the next row after a row is full by
reducing the size of the window by dragging the window boundaries. I reduced the height of the window
to take up less space in the topic. The result on my computer is shown in Figure 17-14 .
FIGURE 17-14
Here the second row is clearly centered. Each button component has been set to its preferred size, which
comfortably accommodates the text for the label. The centering is determined by the alignment constraint
for the layout manager, which defaults to CENTER .
It can also be set to RIGHT or LEFT by using a different constructor. For example, you could have created
the layout manager with the statement:
FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
 
 
Search WWH ::




Custom Search