links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Example of a flow layout implemented with a TableLayout
Last updated at 9:37 am UTC on 13 March 2018
The following example shows how the TableLayout policy may be used to produce a Java FlowLayout manager like effect


 | cont |

 cont := Morph new.
 cont width: 200.
 cont height: 150.

 cont layoutPolicy: TableLayout new.
 cont listDirection: #leftToRight.
 cont wrapCentering: #topLeft.
 cont wrapDirection: #topToBottom.

 20 timesRepeat: [ m:= Morph new. 
                   m height: 25. 
                   m color: Color random. 
                   m width: m width + 20 atRandom - 10. 
                   cont addMorph: m

 cont openInWorld.

Try changing some of the symbols above to see the effects, if any.
You can interactively meddle with the morph by opening its menu, finding the layout->table layout-> submenus and playing.

See also TableLayoutExample with 100 squares