Setting FlowLayout Alignment

You can change the alignment of a FlowLayout in the constructor. Components are normally centered in an applet. You can make them left or right justified instead. To do this just pass one of the defined constants FlowLayout.LEFT, FlowLayout.RIGHT or FlowLayout.CENTER to the constructor, e.g.

 this.setLayout(new FlowLayout(FlowLayout.LEFT));
 this.setLayout(new FlowLayout(FlowLayout.RIGHT));
 this.setLayout(new FlowLayout(FlowLayout.CENTER));

Below you see all three variants:

Applet with five left aligned buttons
Left Alignment

Applet with five centered buttons
Center Alignment

Applet with five right aligned buttons
Right Alignment


Previous | Next | Top | Cafe au Lait

Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified June 30, 1998