Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How do I center a child morph object within the parent object?
Last updated at 11:14 pm UTC on 6 June 2018
Open a Workspace and paste the following code into it.

 parent := RectangleMorph new.
 parent extent: 480@320.
 parent color: Color white.
 parent borderWidth: 50.
 parent borderColor: Color lightBlue.

 child := EllipseMorph new.
 child color: Color red.
 child extent: 180@180.
 child borderWidth: 0.

 parent addMorph: child.

 "CENTER THE CHILD MORPH"
 child center: parent center.

 parent openInHand

Select the code and choose do-it.
RedEllipseMorphCenteredInRectangleMorph.png

tagBeginner